Package org.springframework.kafka.event
Class ConsumerStoppedEvent
- java.lang.Object
-
- java.util.EventObject
-
- org.springframework.context.ApplicationEvent
-
- org.springframework.kafka.event.KafkaEvent
-
- org.springframework.kafka.event.ConsumerStoppedEvent
-
- All Implemented Interfaces:
java.io.Serializable
public class ConsumerStoppedEvent extends KafkaEvent
An event published when a consumer is stopped. While it is best practice to use stateless listeners, you can consume this event to clean up any thread-based resources (remove ThreadLocals, destroy thread-scoped beans etc), as long as the context event multicaster is not modified to use an async task executor. You can also use this event to restart a container that was stopped because a transactional producer was fenced.- Since:
- 2.2
- Author:
- Gary Russell
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ConsumerStoppedEvent.Reason
Reasons for stopping a consumer.
-
Constructor Summary
Constructors Constructor Description ConsumerStoppedEvent(java.lang.Object source, java.lang.Object container, ConsumerStoppedEvent.Reason reason)
Construct an instance with the provided source and container.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ConsumerStoppedEvent.Reason
getReason()
Return the reason why the consumer was stopped.java.lang.String
toString()
-
Methods inherited from class org.springframework.kafka.event.KafkaEvent
getContainer, getSource
-
-
-
-
Constructor Detail
-
ConsumerStoppedEvent
public ConsumerStoppedEvent(java.lang.Object source, java.lang.Object container, ConsumerStoppedEvent.Reason reason)
Construct an instance with the provided source and container.- Parameters:
source
- the container instance that generated the event.container
- the container or the parent container if the container is a child.reason
- the reason.- Since:
- 2.5.8
-
-
Method Detail
-
getReason
public ConsumerStoppedEvent.Reason getReason()
Return the reason why the consumer was stopped.- Returns:
- the reason.
- Since:
- 2.5.8
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.util.EventObject
-
-