You can register for Hazelcast entry events so you are notified when those events occur. Event listeners are cluster-wide: when a listener is registered in one member of cluster, it is actually registered for the events that originated at any member in the cluster. When a new member joins, events originated at the new member are also delivered.
An event is created only if you registered an event listener. If no listener is registered, then no event is created. If you provided a predicate when you registered the event listener, pass the predicate before sending the event to the listener (member/client).
As a rule of thumb, your event listener should not implement heavy processes
in its event methods that block the thread for a long time. If needed, you can
ExecutorService to transfer long running processes to another thread and
thus offload the current listener thread.
|In a failover scenario, events are not highly available and may get lost. However, you can perform workarounds such as configuring the event queue capacity as explained in the Global Event Configuration section.
Hazelcast offers the following event listeners.
For cluster events:
Membership Listener for cluster membership events
Distributed Object Listener for distributed object creation and destruction events
Migration Listener for partition migration start and completion events
Partition Lost Listener for partition lost events
Lifecycle Listener for
Client Listener for client connection events
For distributed object events:
Entry Listener for
Item Listener for
Message Listener for
For Hazelcast JCache implementation:
For Hazelcast clients:
Distributed Object Listener