Class KafkaShareMessageListenerContainerSpec<K,V>

java.lang.Object
org.springframework.integration.dsl.IntegrationComponentSpec<KafkaShareMessageListenerContainerSpec<K,V>, org.springframework.kafka.listener.ShareKafkaMessageListenerContainer<K,V>>
org.springframework.integration.kafka.dsl.KafkaShareMessageListenerContainerSpec<K,V>
Type Parameters:
K - the key type.
V - the value type.
All Implemented Interfaces:
org.springframework.beans.factory.DisposableBean, org.springframework.beans.factory.FactoryBean<org.springframework.kafka.listener.ShareKafkaMessageListenerContainer<K,V>>, org.springframework.beans.factory.InitializingBean, org.springframework.context.Lifecycle, org.springframework.context.Phased, org.springframework.context.SmartLifecycle

public class KafkaShareMessageListenerContainerSpec<K,V> extends org.springframework.integration.dsl.IntegrationComponentSpec<KafkaShareMessageListenerContainerSpec<K,V>, org.springframework.kafka.listener.ShareKafkaMessageListenerContainer<K,V>>
A helper class in the Builder pattern style to delegate options to the ShareKafkaMessageListenerContainer.

Only options that the share consumer container actually honors are exposed here; unlike KafkaMessageListenerContainerSpec, options such as ackMode, pollTimeout, consumerRebalanceListener, and idleEventInterval are not applicable to share consumers and are deliberately omitted.

Since:
7.2
  • Method Details

    • id

      Overrides:
      id in class org.springframework.integration.dsl.IntegrationComponentSpec<KafkaShareMessageListenerContainerSpec<K,V>, org.springframework.kafka.listener.ShareKafkaMessageListenerContainer<K,V>>
    • concurrency

      public KafkaShareMessageListenerContainerSpec<K,V> concurrency(int concurrency)
      Specify the number of consumer threads to create within the container. Each thread creates its own ShareConsumer instance and all of them participate in the same share group.
      Parameters:
      concurrency - the concurrency.
      Returns:
      the spec.
      See Also:
      • ShareKafkaMessageListenerContainer.setConcurrency(int)
    • clientId

      public KafkaShareMessageListenerContainerSpec<K,V> clientId(String clientId)
      Set the client.id to use for the consumer(s).
      Parameters:
      clientId - the client id.
      Returns:
      the spec.
      See Also:
      • ShareKafkaMessageListenerContainer.setClientId(String)
    • groupId

      public KafkaShareMessageListenerContainerSpec<K,V> groupId(String groupId)
      Set the group id for this container. Overrides any group.id property provided by the consumer factory configuration.
      Parameters:
      groupId - the group id.
      Returns:
      the spec.
      See Also:
      • ConsumerProperties.setGroupId(String)
    • shareAckMode

      public KafkaShareMessageListenerContainerSpec<K,V> shareAckMode(org.springframework.kafka.listener.ContainerProperties.ShareAckMode shareAckMode)
      Set the acknowledgment mode for the container.
      Parameters:
      shareAckMode - the ContainerProperties.ShareAckMode; default EXPLICIT.
      Returns:
      the spec.
      See Also:
      • ContainerProperties.setShareAckMode(ContainerProperties.ShareAckMode)
    • shareAcknowledgmentTimeout

      public KafkaShareMessageListenerContainerSpec<K,V> shareAcknowledgmentTimeout(Duration shareAcknowledgmentTimeout)
      Set the timeout for detecting unacknowledged records in ContainerProperties.ShareAckMode.MANUAL mode. Default 30 seconds.
      Parameters:
      shareAcknowledgmentTimeout - the timeout.
      Returns:
      the spec.
      See Also:
      • ContainerProperties.setShareAcknowledgmentTimeout(Duration)
    • syncShareCommits

      public KafkaShareMessageListenerContainerSpec<K,V> syncShareCommits(boolean syncShareCommits)
      Set whether to use commitSync() or commitAsync() for share consumer acknowledgment commits. Default true (sync).
      Parameters:
      syncShareCommits - true to use commitSync().
      Returns:
      the spec.
      See Also:
      • ContainerProperties.setSyncShareCommits(boolean)
    • acknowledgementCommitCallback

      public KafkaShareMessageListenerContainerSpec<K,V> acknowledgementCommitCallback(org.apache.kafka.clients.consumer.AcknowledgementCommitCallback acknowledgementCommitCallback)
      Set the callback to be invoked when acknowledgement commits complete; useful with syncShareCommits(false) for visibility into async commit success or failure.
      Parameters:
      acknowledgementCommitCallback - the callback.
      Returns:
      the spec.
      See Also:
      • ContainerProperties.setAcknowledgementCommitCallback(AcknowledgementCommitCallback)
    • shareConsumerRecordRecoverer

      public KafkaShareMessageListenerContainerSpec<K,V> shareConsumerRecordRecoverer(org.springframework.kafka.listener.ShareConsumerRecordRecoverer shareConsumerRecordRecoverer)
      Set a ShareConsumerRecordRecoverer to use when a listener throws an exception. The recoverer determines whether to accept, release, or reject the failed record. Default: reject (archive, no redelivery).
      Parameters:
      shareConsumerRecordRecoverer - the recoverer.
      Returns:
      the spec.
      See Also:
      • AbstractShareKafkaMessageListenerContainer.setShareConsumerRecordRecoverer(ShareConsumerRecordRecoverer)
    • listenerTaskExecutor

      public KafkaShareMessageListenerContainerSpec<K,V> listenerTaskExecutor(org.springframework.core.task.AsyncTaskExecutor consumerTaskExecutor)
      Set the executor for threads that poll the consumer(s). Needs at least concurrency threads.
      Parameters:
      consumerTaskExecutor - the executor.
      Returns:
      the spec.
      See Also:
      • ContainerProperties.setListenerTaskExecutor(AsyncTaskExecutor)
    • consumerStartTimeout

      public KafkaShareMessageListenerContainerSpec<K,V> consumerStartTimeout(Duration consumerStartTimeout)
      Set the maximum time to wait for the consumer thread(s) to start.
      Parameters:
      consumerStartTimeout - the timeout.
      Returns:
      the spec.
      See Also:
      • ContainerProperties.setConsumerStartTimeout(Duration)