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:
pong
requires no additional keys.
It is the response to the ping
request from client to bridge.
message
: (string, required) The type of error, one of:"access_denied"
,"unknown_address"
,"unknown_type"
For a regular message, the object will also contain:
address
: (string, required) Destination address.body
: (any, required) Message content as a JSON valid type.headers
: (object, optional) Headers as a JSON object with String values.replyAddress
: (string, optional) Address for replying to.send
: (boolean, required) Will betrue
if the message is a send,false
if 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
: (any, required) Message content as a JSON valid type.headers
: (object, optional) Headers as a JSON object with String values.replyAddress
: (string, optional) Address for replying to.
When type is "send" if the message contains the key failureCode the original message will be failed, content is then:
address
: (string, required) Destination address to failfailureCode
: (integer, required) Failure codemessage
: (string, required) Message that explains the failure
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) {
...
});
};