This is a TCP eventbus bridge implementation.
The protocol is quite simple:
- 4bytes int32 message length (big endian encoding)
- json string (encoded in UTF-8)
Every JSON message will include a type key, with a string
value. Each type is shown below, along with the companion keys for
that type:
message: (string, required) The type of error, one of:"access_denied","address_required","unknown_address","unknown_type"
For a regular message, the object will also contain:
address: (string, required) Destination address.body: (object, required) Message content as a JSON object.headers: (object, optional) Headers as a JSON object with String values.replyAddress: (string, optional) Address for replying to.send: (boolean, required) Will betrueif the message is a send,falseif a publish.
When a message from the client requests a reply, and that reply fails, the object will instead contain:
failureCode: (number, required) The failure codefailureType: (string, required) The failure namemessage: (string, required) The message from the exception that signaled the failure
The JSON object must contain a type key with a string value. Each
type is shown below, along with the companion keys for that type:
address: (string, required) Destination addressbody: (object, required) Message content as a JSON object.headers: (object, optional) Headers as a JSON object with String values.replyAddress: (string, optional) Address for replying to.
address: (string, required) Destination addressheaders: (object, optional) Headers as a JSON object with String values.
ping requires no additional keys.
An example nodejs client is provided as an example using the same API as SockJS bridge e.g.:
var EventBus = require('tcp-vertx-eventbus');
var eb = new EventBus('localhost', 7000);
eb.onopen = function () {
// send a echo message
eb.send('echo', {value: 'vert.x'}, function (err, res) {
...
});
};