Package org.springframework.kafka.event
Class KafkaEvent
- java.lang.Object
-
- java.util.EventObject
-
- org.springframework.context.ApplicationEvent
-
- org.springframework.kafka.event.KafkaEvent
-
- All Implemented Interfaces:
java.io.Serializable
- Direct Known Subclasses:
ConsumerFailedToStartEvent
,ConsumerPartitionPausedEvent
,ConsumerPartitionResumedEvent
,ConsumerPausedEvent
,ConsumerResumedEvent
,ConsumerStartedEvent
,ConsumerStartingEvent
,ConsumerStoppedEvent
,ConsumerStoppingEvent
,ContainerStoppedEvent
,ListenerContainerIdleEvent
,ListenerContainerNoLongerIdleEvent
,ListenerContainerPartitionIdleEvent
,ListenerContainerPartitionNoLongerIdleEvent
,NonResponsiveConsumerEvent
public abstract class KafkaEvent extends org.springframework.context.ApplicationEvent
Base class for events.- Author:
- Gary Russell
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description KafkaEvent(java.lang.Object source, java.lang.Object container)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> T
getContainer(java.lang.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.<T> T
getSource(java.lang.Class<T> type)
Get the container (source) that published the event.
-
-
-
Method Detail
-
getContainer
public <T> T getContainer(java.lang.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(Class)
-
getSource
public <T> T getSource(java.lang.Class<T> type)
Get the container (source) that published the event. This is provided as an alternative toEventObject.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:
getContainer(Class)
,EventObject.getSource()
-
-