To catch and handle an event published in any node of cluster, EventsHandler must be registered first.
EventHandler handler = new EventHandler() { @Override public void onEvent(String name, String xmlns, Element event) { // TODO } }; eventBus.addHandler("EventName", "tigase:demo", handler);
It is possible to register handler for all events with a specific xmlns such as tigase:demo
below:
eventBus.addHandler(null, "tigase:demo", handler);
Events created on others cluster node, will have attribute remote
set to true
and attribute source
set to event creator node name:
<EventName xmlns="tigase:demo" remote="true" source="node1.example"> <sample_value>1</sample_value> </EventName>