Class ListenerContainerPauseService
java.lang.Object
org.springframework.kafka.listener.ListenerContainerPauseService
Service for pausing and resuming of
MessageListenerContainer
.- Since:
- 2.9
- Author:
- Jan Marincek, Gary Russell
-
Constructor Summary
ConstructorsConstructorDescriptionListenerContainerPauseService
(ListenerContainerRegistry registry, TaskScheduler scheduler) Create an instance with the provided registry and scheduler. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Pause the listener by given id.void
pause
(MessageListenerContainer messageListenerContainer, Duration pauseDuration) Pause the listener by given container instance.void
pausePartition
(MessageListenerContainer messageListenerContainer, org.apache.kafka.common.TopicPartition partition, Duration pauseDuration) Pause consumption from a given partition for the duration.void
Resume the listener container by given id.void
resume
(MessageListenerContainer messageListenerContainer) Resume the listener container.
-
Constructor Details
-
ListenerContainerPauseService
public ListenerContainerPauseService(@Nullable ListenerContainerRegistry registry, TaskScheduler scheduler) Create an instance with the provided registry and scheduler.- Parameters:
registry
- the registry or null.scheduler
- the scheduler.
-
-
Method Details
-
pause
Pause the listener by given id. Checks if the listener has already been requested to pause. Sets executor schedule for resuming the same listener after pauseDuration.- Parameters:
listenerId
- the id of the listenerpauseDuration
- duration between pause() and resume() actions
-
pause
Pause the listener by given container instance. Checks if the listener has already been requested to pause. Sets executor schedule for resuming the same listener after pauseDuration.- Parameters:
messageListenerContainer
- the listener containerpauseDuration
- duration between pause() and resume() actions
-
pausePartition
public void pausePartition(MessageListenerContainer messageListenerContainer, org.apache.kafka.common.TopicPartition partition, Duration pauseDuration) Pause consumption from a given partition for the duration.- Parameters:
messageListenerContainer
- the container.partition
- the partition.pauseDuration
- the duration.
-
resume
Resume the listener container by given id.- Parameters:
listenerId
- the id of the listener
-
resume
Resume the listener container.- Parameters:
messageListenerContainer
- the listener container
-