com.hazelcast.spi

## Interface EventService

-     public interface EventService

  Component responsible for handling events like topic events or map.listener events. The events are divided into topics.

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `deregisterAllListeners(String serviceName, String topic)` Deregisters all listeners belonging to the given service and topic.
    `boolean` | `deregisterListener(String serviceName, String topic, Object id)` Deregisters a listener with the given registration ID.
    `void` | `executeEventCallback(Runnable callback)` Executes an event callback on a random event thread.
    `int` | `getEventQueueCapacity()` Returns the queue capacity per event thread.
    `int` | `getEventQueueSize()` Returns the current total event queue size.
    `int` | `getEventThreadCount()` Returns the event thread count.
    `Collection<EventRegistration>` | `getRegistrations(String serviceName, String topic)` Returns all registrations belonging to the given service and topic.
    `EventRegistration[]` | `getRegistrationsAsArray(String serviceName, String topic)` Returns all registrations belonging to the given service and topic as an array.
    `boolean` | `hasEventRegistration(String serviceName, String topic)` Returns true if a listener is registered with the specified service name and topic.
    `void` | `publishEvent(String serviceName, Collection<EventRegistration> registrations, Object event, int orderKey)` Publishes an event for multiple event registrations.
    `void` | `publishEvent(String serviceName, EventRegistration registration, Object event, int orderKey)` Publishes an event for a specific event registration.
    `void` | `publishEvent(String serviceName, String topic, Object event, int orderKey)` Publishes an event for all event registrations belonging to the specified service name and topic.
    `void` | `publishRemoteEvent(String serviceName, Collection<EventRegistration> registrations, Object event, int orderKey)` Publishes an event for multiple event registrations, excluding local ones.
    `EventRegistration` | `registerListener(String serviceName, String topic, EventFilter filter, Object listener)` Registers a listener on all cluster nodes with an event filter.
    `EventRegistration` | `registerListener(String serviceName, String topic, Object listener)` Registers a listener on all cluster nodes.
    `EventRegistration` | `registerLocalListener(String serviceName, String topic, EventFilter filter, Object listener)` Registers a local only listener with an event filter.
    `EventRegistration` | `registerLocalListener(String serviceName, String topic, Object listener)` Registers a local only listener.

- - ### Method Detail

    - #### getEventThreadCount

          int getEventThreadCount()

      Returns the event thread count.
      Returns:
        the event thread count
      See Also:
        `GroupProperty.EVENT_THREAD_COUNT`

    - #### getEventQueueCapacity

          int getEventQueueCapacity()

      Returns the queue capacity per event thread.
      Returns:
        the queue capacity per event thread
      See Also:
        `GroupProperty.EVENT_QUEUE_CAPACITY`

    - #### getEventQueueSize

          int getEventQueueSize()

      Returns the current total event queue size.
      Returns:
        the current total event queue size

    - #### registerLocalListener

          EventRegistration registerLocalListener(String serviceName,
                                                  String topic,
                                                  Object listener)

      Registers a local only listener.
      Parameters:
        `serviceName` - service name
        `topic` - topic name
        `listener` - listener instance
      Returns:
        event registration

    - #### registerLocalListener

          EventRegistration registerLocalListener(String serviceName,
                                                  String topic,
                                                  EventFilter filter,
                                                  Object listener)

      Registers a local only listener with an event filter.
      Parameters:
        `serviceName` - service name
        `topic` - topic name
        `filter` - event filter
        `listener` - listener instance
      Returns:
        event registration

    - #### registerListener

          EventRegistration registerListener(String serviceName,
                                             String topic,
                                             Object listener)

      Registers a listener on all cluster nodes.
      Parameters:
        `serviceName` - service name
        `topic` - topic name
        `listener` - listener instance
      Returns:
        event registration

    - #### registerListener

          EventRegistration registerListener(String serviceName,
                                             String topic,
                                             EventFilter filter,
                                             Object listener)

      Registers a listener on all cluster nodes with an event filter.
      Parameters:
        `serviceName` - service name
        `topic` - topic name
        `filter` - event filter
        `listener` - listener instance
      Returns:
        event registration

    - #### deregisterListener

          boolean deregisterListener(String serviceName,
                                     String topic,
                                     Object id)

      Deregisters a listener with the given registration ID.
      Parameters:
        `serviceName` - service name
        `topic` - topic name
        `id` - registration ID
      Returns:
        true if listener is deregistered successfully, false otherwise
      See Also:
        `EventRegistration.getId()`, `registerListener(String, String, Object)`, `registerLocalListener(String, String, Object)`

    - #### deregisterAllListeners

          void deregisterAllListeners(String serviceName,
                                      String topic)

      Deregisters all listeners belonging to the given service and topic.
      Parameters:
        `serviceName` - service name
        `topic` - topic name

    - #### getRegistrations

          Collection<EventRegistration> getRegistrations(String serviceName,
                                                         String topic)

      Returns all registrations belonging to the given service and topic.
      Parameters:
        `serviceName` - service name
        `topic` - topic name
      Returns:
        registrations

    - #### getRegistrationsAsArray

          EventRegistration[] getRegistrationsAsArray(String serviceName,
                                                      String topic)

      Returns all registrations belonging to the given service and topic as an array.
      Parameters:
        `serviceName` - service name
        `topic` - topic name
      Returns:
        registrations array

    - #### hasEventRegistration

          boolean hasEventRegistration(String serviceName,
                                       String topic)

      Returns true if a listener is registered with the specified service name and topic.
      Parameters:
        `serviceName` - service name
        `topic` - topic name
      Returns:
        true if a listener is registered with specified service name and topic, false otherwise.

    - #### publishEvent

          void publishEvent(String serviceName,
                            String topic,
                            Object event,
                            int orderKey)

      Publishes an event for all event registrations belonging to the specified service name and topic. All events with the same `orderKey` are ordered, otherwise the order is not preserved.

      NOTE : The order may not be preserved in case the event needs to be republished (e.g. when the registration is not on this node and the event has to be retransmitted)

      Parameters:
        `serviceName` - service name
        `topic` - topic name
        `event` - event object
        `orderKey` - the order key for this event. All events with the same order key are ordered.

    - #### publishEvent

          void publishEvent(String serviceName,
                            EventRegistration registration,
                            Object event,
                            int orderKey)

      Publishes an event for a specific event registration. All events with the same `orderKey` are ordered, otherwise the order is not preserved.

      NOTE : The order may not be preserved in case the event needs to be republished (e.g. when the registration is not on this node and the event has to be retransmitted)

      Parameters:
        `serviceName` - service name
        `registration` - event registration
        `event` - event object
        `orderKey` - the order key for this event. All events with the same order key are ordered.

    - #### publishEvent

          void publishEvent(String serviceName,
                            Collection<EventRegistration> registrations,
                            Object event,
                            int orderKey)

      Publishes an event for multiple event registrations. All events with the same `orderKey` are ordered, otherwise the order is not preserved.

      NOTE : The order may not be preserved in case the event needs to be republished (e.g. when the registration is not on this node and the event has to be retransmitted)

      Parameters:
        `serviceName` - service name
        `registrations` - multiple event registrations
        `event` - event object
        `orderKey` - the order key for this event. All events with the same order key are ordered.

    - #### publishRemoteEvent

          void publishRemoteEvent(String serviceName,
                                  Collection<EventRegistration> registrations,
                                  Object event,
                                  int orderKey)

      Publishes an event for multiple event registrations, excluding local ones. All events with the same `orderKey` are ordered, otherwise the order is not preserved.

      NOTE : The order may not be preserved in case the event needs to be republished (e.g. when the registration is not on this node and the event has to be retransmitted)

      Parameters:
        `serviceName` - service name
        `registrations` - multiple event registrations
        `event` - event object
        `orderKey` - the order key for this event. All events with the same order key are ordered.

    - #### executeEventCallback

          void executeEventCallback(Runnable callback)

      Executes an event callback on a random event thread.

      If `callback` is an instance of `StripedRunnable`, then `StripedRunnable.getKey()` will be used as order key to pick event thread.

      Parameters:
        `callback` - the callback to execute on a random event thread
      See Also:
        `StripedRunnable`

Copyright © 2018. All rights reserved.