Distributed Events

You can register for Hazelcast entry events so you will be 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 events that originated at any member in the cluster. When a new member joins, events originated at the new member will also be delivered.

An Event is created only if you registered an event listener. If no listener is registered, then no event will be 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 which block the thread for a long time. If needed, you can use ExecutorService to transfer long running processes to another thread and thus offload the current listener thread.

Event Listeners for Hazelcast Members

Hazelcast offers the following event listeners:

  • Membership Listener for cluster membership events.
  • Distributed Object Listener for distributed object creation and destroy events.
  • Migration Listener for partition migration start and complete events.
  • Partition Lost Listener for partition lost events.
  • Lifecycle Listener for HazelcastInstance lifecycle events.
  • Entry Listener for IMap and MultiMap entry events (please refer to the Listening to Map Events section).
  • Item Listener for IQueue, ISet and IList item events (please refer to the Event Registration and Configuration parts of the sections Set and List).
  • Message Listener for ITopic message events.
  • Client Listener for client connection events.