Accessor: net/VertxPublish


Publish to a Vert.x event bus, which is a peer-to-peer publish-and-subscribe system. The published data will be sent to any subscriber that subscribes to the same address and runs in the same Vertx cluster (see the VertxSubscribe accessor). The Vertx cluster normally includes all machines that hear multicast packets sent by the machine hosting this accessor.

The input to be published can be any data type supported by accessors that has a string representation in JSON syntax. The data will be converted to a string in JSON format and sent to the event bus. The VertxSubscribe accessor will parse that string and output the data in the native format of its host.

If the broadcast input is set to false, then instead of broadcasting the message to all subscribers, the Vertx bus will pick exactly one subscriber and send the message to it. The bus picks the subscribers in an approximately round-robin fashion. If the subscriber replies to this message, then that will reply (required to be also be a JSON object) will be produced on the reply output port.

The busHost input specifies the name of the network interface through which to connect to the Vert.x event bus cluster, and busHostPort specifies the port to use for this. Normally, you can leave these at their default values unless you need to need to use a network interface that is not 'localhost' or you need to use a particular port. These two inputs are examined only at initialization time, so changing them during execution of a swarmlet will have no effect.

  • $$Id$$
  • Patricia Derler, Edward A. Lee, Ben Zhang
Name Type Description
address string The event bus address, which is the name of the event stream. This defaults to 'topic'.
message The message to publish.
broadcast boolean Indicator of whether to send to all subscribers or just one. This defaults to true, which means to send to all subscribers.
Name Type Description
reply The reply, if any, received after a point-to-point send (where broadcast == false).
Name Type Description
busHost string The name of the network interface to use for the Vert.x event bus. A blank string is interpreted as 'localhost' (the default).
busHostPort int The port for the Vert.x event bus. A value of 0 indicates to just find an available port (the default).


(static) setup()

Set up the accessor by defining the inputs and outputs.