Skip to content

Command Queue

Michael Röder edited this page Apr 12, 2017 · 7 revisions

The command queue is used as a central message bus to orchestrate the single components.

Structure of a message

The structure of the message is described in the following table.

start byte length meaning
0 4 session id length as 32 bit integer (s)
4 s session id
s + 4 1 Command id as byte
s + 5 data (optional)

It can be seen that the first part of a message contains the session id of the benchmark to which the message belongs to (preceded by the session id length). After that, the id of the "command" follows as single byte. Some messages might have additional data that is simply added at the end of the message behind the command id.

API

The command queue uses a RabbitMQ Exchange. Connecting a component to this exchange can be done as described in the RabbitMQ Publish/Subscribe tutorial. The exchange itself has to be setup with:

  • name="hobbit.command"
  • type="fanout"
  • durable=false
  • autoDelete=true
  • and no additional arguments.

The queue that is bound to the exchange can have an autogenerated name. The queue can be used to send messages to the exchange. Additionally, a consumer should be bound to the queue to be able to receive messages from the exchange.

Predefined command ids

The platform uses already predefined command ids. They can be reused by benchmark and system implementations if they are interacting with the platform. The predefined commands can be found in https://github.com/hobbit-project/core/blob/master/src/main/java/org/hobbit/core/Commands.java

For implementing components, it is possible to use other than the predefined command ids. In this case it should be made sure that the used command ids do not overlap with the predefined ids. In general, it is recommended to use ids > 100 for new command ids.