This is a TCP eventbus bridge implementation.
The protocol is quite simple:
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:
type: "pong"
pong
requires no additional keys.
It is the response to the ping
request from client to bridge.
type: "err"
message
: (string, required) The type of error, one of:
"access_denied"
, "unknown_address"
, "unknown_type"
type: "message"
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 be true
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 failureThe JSON object must contain a type
key with a string value. Each
type is shown below, along with the companion keys for that type:
type: "send"
, type: "publish"
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 failuretype: "register"
, type: "unregister"
address
: (string, required) Destination addressheaders
: (object, optional) Headers as a JSON object with String values.type: "ping"
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) {
...
});
};