public class EventBusHelper extends VertxHelperBase
For information about the Vert.x event bus, see http://vertx.io/core_manual_java.html#the-event-bus.
VertxHelperBase.AccessorVerticle
HelperBase.DATA_TYPE
_verticle
_actor, _currentObj
Constructor and Description |
---|
EventBusHelper(java.lang.Object actor,
jdk.nashorn.api.scripting.ScriptObjectMirror vertxBusJS,
int clusterPort,
java.lang.String clusterHostname)
Create an EventBusHelper for the specified actor and
VertxBus JavaScript object for the event bus at the
specified network interface (port and hostname).
|
Modifier and Type | Method and Description |
---|---|
void |
publish(java.lang.String address,
java.lang.String message)
Publish text data onto the Vertx event bus.
|
void |
send(java.lang.String address,
java.lang.String message)
Send text data to exactly one recipient on the Vertx event bus.
|
void |
send(java.lang.String address,
java.lang.String message,
java.lang.Object replyHandler)
Send text data to exactly one recipient on the Vertx event bus
and handle the reply by invoking the specified function.
|
void |
setReply(java.lang.String reply)
Set the reply to send in response to any point-to-point
events received in the future.
|
void |
subscribe(java.lang.String address)
Subscribe to the specified address on the event bus.
|
void |
unsubscribe(java.lang.String address)
Unsubscribe the associated JavaScript object as a subscriber to the
specified address on the event bus.
|
_issueOrDeferResponse, _processPendingJob, _setBusy, closeVertx, getHelper, getImageTypes, reset, submit, supportedReceiveTypes, supportedSendTypes, undeploy
_appendNumericToBuffer, _appendToBuffer, _error, _error, _error, _error, _extractFromBuffer, _issueResponse, _removeDuplicates, _sizeOfType, _toJavaBytes, _toJSArray, getHelping
public EventBusHelper(java.lang.Object actor, jdk.nashorn.api.scripting.ScriptObjectMirror vertxBusJS, int clusterPort, java.lang.String clusterHostname)
If the clusterHostname is null, then this will use an unclustered instance of Vertx whose event bus will not communicate with any other instances of Vertx. The clusterHostname is something like "localhost" or "10.0.0.4", and it specifies a local network device over which to listen for cluster connections (e.g. WiFi or Ethernet).
The clusterPort is the tcp/ip port to which to listen for cluster connections. The default for clusterPort for Vertx is 25500. If clusterHostname is null, then the default clusterPort value is used.
actor
- The actor that will publish or subscribe to the
event bus.vertxBusJS
- The VertxBus JavaScript object that will
publish and subscribe to the event bus.clusterPort
- The port over which to listen for cluster
connections.clusterHostname
- The host interface over which to listen
for cluster connections, or null to create an unclustered
EventBusHelper.public void publish(java.lang.String address, java.lang.String message)
address
- The address, (topic, channel name, stream ID,...)message
- A message to be published, as a string.public void send(java.lang.String address, java.lang.String message)
setReply(String)
, then if an when the reply is received,
the associated JavaScript object's reply() function will be invoked.address
- The address, (topic, channel name, stream ID,...)message
- A message to be published, as a string.public void send(java.lang.String address, java.lang.String message, java.lang.Object replyHandler)
setReply(String)
, then if an when the reply is received,
the associated JavaScript object's reply() function will be invoked.address
- The address, (topic, channel name, stream ID,...)message
- A message to be published, as a string.replyHandler
- The handler for the reply.public void setReply(java.lang.String reply)
reply
- A reply to send when an event is received, or null
to not send any replies.public void subscribe(java.lang.String address)
address
- The address on the bus to subscribe to.unsubscribe(String)
public void unsubscribe(java.lang.String address)
address
- The address on the bus to unsubscribe to, or null to
unsubscribe to all addresses.subscribe(String)