Class KafkaEvent

All Implemented Interfaces:
Serializable
Direct Known Subclasses:
ConsumerFailedToStartEvent, ConsumerPartitionPausedEvent, ConsumerPartitionResumedEvent, ConsumerPausedEvent, ConsumerResumedEvent, ConsumerRetryAuthEvent, ConsumerRetryAuthSuccessfulEvent, ConsumerStartedEvent, ConsumerStartingEvent, ConsumerStoppedEvent, ConsumerStoppingEvent, ContainerStoppedEvent, ListenerContainerIdleEvent, ListenerContainerNoLongerIdleEvent, ListenerContainerPartitionIdleEvent, ListenerContainerPartitionNoLongerIdleEvent, NonResponsiveConsumerEvent

public abstract class KafkaEvent extends ApplicationEvent
Base class for events.
Author:
Gary Russell
See Also:
  • Constructor Details

    • KafkaEvent

      public KafkaEvent(Object source, Object container)
  • Method Details

    • getContainer

      public <T> T getContainer(Class<T> type)
      Get the container for which the event was published, which will be the parent container if the source that emitted the event is a child container, or the source itself otherwise. The type is required here to avoid a dependency tangle between the event and listener packages.
      Type Parameters:
      T - the type.
      Parameters:
      type - the container type (e.g. MessageListenerContainer.class).
      Returns:
      the container.
      Since:
      2.2.1
      See Also:
    • getSource

      public <T> T getSource(Class<T> type)
      Get the container (source) that published the event. This is provided as an alternative to EventObject.getSource() to avoid the need to cast in user code. The type is required here to avoid a dependency tangle between the event and listener packages.
      Type Parameters:
      T - the type.
      Parameters:
      type - the container type (e.g. MessageListenerContainer.class).
      Returns:
      the container.
      Since:
      2.2.1
      See Also: