/MPSS

Primary LanguageJava

Multi Publish Subscribe Service

MPSS (Multi Publish Subscribe Service), is a service that can be used where a distributed architecture is in place. A subscriber can subscribe to multiple subjects, and a publisher can likewise publish to various subjects. This can be very useful in multi agent, and autonomous system.
There are key features the make MPSS stand out:

  • Ability to publish and subscribe to different subjects at the same time with the same node
  • No strict Interface Description Language (IDL) declaration. (Flexibility of data to be sent and received).
  • Data is passed around using JSON.

Software Architecture

Software Architecture

When a subscriber node registers its interest in a subject or multiple subjects, a message broker is assigned to it which takes the necessary messages meant for the subscriber from the message queue based on the subjects of interest. The publisher also has a message broker that puts its published messages on the queue with respect to the subjects it is publishing to. All communication are in TCP and goes through the Network Bus.

Registering Nodes

To register a node, a JSON message is sent. This message contains the node type i.e Subscriber or Publisher, the subjects being subscribed or published to, the time stamp and the data when necessary.

Subscribers

To register as a subscriber, connect to the network bus (which is where ever the com.chidiebere.MPSService is running)
and send a JSON message in this format.

{
  "type" : "Subscriber",
  "subjects" : ["Subject1", "Subject2", "Subject3"],
  "_timeStamp" : 12345678987
}

After the message has been sent and terminated with a 0 byte, stay connected to receive any message published on the subjects subscribed to.

Publishers

To register as a publisher, connect to the network bus (which is where ever the com.chidiebere.MPSService is running)
and send a JSON message in this format.

{
  "type" : "Publisher",
  "subjects" : ["Subject1", "Subject2", "Subject3"],
  "_timeStamp" : 12345678987,
  "data" : {
       "Subject1" : {
              "string" : "I am subject1",
              "int" : 1234
        },
       "Subject2" : {
              "string" : "I am subject2",
              "float" : 56.90
        },
       "Subject3" : {
               "string" : "I am subject3",
               "array" : [1, 2, 3, 4]
       }
  }
}
Message Termination

To indicate the end of a message, send a 0 byte in other for the JSON to be parsed correctly.

Building and Running the Service

MPSS depends on MPSCore which is a Maven project. Clone, build and install it as a Maven dependency or package the Jar using mvn package and add it as a library to the project.

Running the Service

To run the service, you have to pass the host and port as arguments e.g. MPSService 10.10.16.123 12865, if no argument is passed, localhost will be used as the host and 12345 will be used as the port.