Class ListenerContainerPauseService

java.lang.Object
org.springframework.kafka.listener.ListenerContainerPauseService

public class ListenerContainerPauseService extends Object
Service for pausing and resuming of MessageListenerContainer.
Since:
2.9
  • Constructor Details

    • ListenerContainerPauseService

      public ListenerContainerPauseService(@Nullable ListenerContainerRegistry registry, org.springframework.scheduling.TaskScheduler scheduler)
      Create an instance with the provided registry and scheduler.
      Parameters:
      registry - the registry or null.
      scheduler - the scheduler.
  • Method Details

    • pause

      public void pause(String listenerId, Duration pauseDuration)
      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 listener
      pauseDuration - duration between pause() and resume() actions
    • pause

      public void pause(MessageListenerContainer messageListenerContainer, Duration pauseDuration)
      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 container
      pauseDuration - 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

      public void resume(String listenerId)
      Resume the listener container by given id.
      Parameters:
      listenerId - the id of the listener
    • resume

      public void resume(MessageListenerContainer messageListenerContainer)
      Resume the listener container.
      Parameters:
      messageListenerContainer - the listener container