Annotation Interface PulsarListener


Annotation that marks a method to be the target of a Pulsar message listener on the specified topics. The containerFactory() identifies the PulsarListenerContainerFactory to use to build the Pulsar listener container. If not set, a default container factory is assumed to be available with a bean name of pulsarListenerContainerFactory unless an explicit default has been provided through configuration.

Processing of @PulsarListener annotations is performed by registering a PulsarListenerAnnotationBeanPostProcessor. This can be done manually or, more conveniently, through EnablePulsar annotation.

Author:
Soby Chacko, Chris Bono, Alexander Preuß
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    Override the container default ack mode of BATCH.
    The bean name or a 'SpEL' expression that resolves to a RedeliveryBackoff to use on the consumer to control the redelivery backoff of messages after an acknowledgment timeout.
    Set to true or false, to override the default setting in the container factory.
    boolean
    Activate batch consumption.
    A pseudo bean name used in SpEL expressions within this annotation to reference the current bean within which this listener is defined.
    Override the container factory's concurrency setting for this listener.
    The bean name of the PulsarListenerContainerFactory to use to create the message listener container responsible to serve this endpoint.
    The bean name or a 'SpEL' expression that resolves to a DeadLetterPolicy to use on the consumer to configure a dead letter policy for message redelivery.
    The unique identifier of the container for this listener.
    The bean name or a 'SpEL' expression that resolves to a RedeliveryBackoff to use on the consumer to control the redelivery backoff of messages after a negative ack.
    Pulsar consumer properties; they will supersede any properties with the same name defined in the consumer factory (if the consumer factory supports property overrides).
    The bean name or a 'SpEL' expression that resolves to a PulsarConsumerErrorHandler which is used as a Spring provided mechanism to handle errors from processing the message.
    org.apache.pulsar.common.schema.SchemaType
    Pulsar schema type for this listener.
    Pulsar subscription name associated with this listener.
    org.apache.pulsar.client.api.SubscriptionType
    Pulsar subscription type for this listener.
    Topic patten to listen to.
    Topics to listen to.
  • Element Details

    • id

      String id
      The unique identifier of the container for this listener.

      If none is specified an auto-generated id is used.

      SpEL #{...} and property place holders ${...} are supported.

      Returns:
      the id for the container managing for this endpoint.
      See Also:
      Default:
      ""
    • subscriptionName

      String subscriptionName
      Pulsar subscription name associated with this listener.
      Returns:
      the subscriptionName for this Pulsar listener endpoint.
      Default:
      ""
    • subscriptionType

      org.apache.pulsar.client.api.SubscriptionType subscriptionType
      Pulsar subscription type for this listener.
      Returns:
      the subscriptionType for this listener
      Default:
      Exclusive
    • schemaType

      org.apache.pulsar.common.schema.SchemaType schemaType
      Pulsar schema type for this listener.
      Returns:
      the schemaType for this listener
      Default:
      NONE
    • containerFactory

      String containerFactory
      The bean name of the PulsarListenerContainerFactory to use to create the message listener container responsible to serve this endpoint.

      If not specified, the default container factory is used, if any. If a SpEL expression is provided (#{...}), the expression can either evaluate to a container factory instance or a bean name.

      Returns:
      the container factory bean name.
      Default:
      ""
    • topics

      String[] topics
      Topics to listen to.
      Returns:
      a comma separated list of topics to listen from.
      Default:
      {}
    • topicPattern

      String topicPattern
      Topic patten to listen to.
      Returns:
      topic pattern to listen to.
      Default:
      ""
    • autoStartup

      String autoStartup
      Set to true or false, to override the default setting in the container factory. May be a property placeholder or SpEL expression that evaluates to a Boolean or a String, in which case the Boolean.parseBoolean(String) is used to obtain the value.

      SpEL #{...} and property place holders ${...} are supported.

      Returns:
      true to auto start, false to not auto start.
      Default:
      ""
    • batch

      boolean batch
      Activate batch consumption.
      Returns:
      whether this listener is in batch mode or not.
      Default:
      false
    • beanRef

      String beanRef
      A pseudo bean name used in SpEL expressions within this annotation to reference the current bean within which this listener is defined. This allows access to properties and methods within the enclosing bean. Default '__listener'.

      Returns:
      the pseudo bean name.
      Default:
      "__listener"
    • properties

      String[] properties
      Pulsar consumer properties; they will supersede any properties with the same name defined in the consumer factory (if the consumer factory supports property overrides).

      Supported Syntax

      The supported syntax for key-value pairs is the same as the syntax defined for entries in a Java properties file:

      • key=value
      • key:value
      • key value
      group.id and client.id are ignored.

      SpEL #{...} and property place holders ${...} are supported. SpEL expressions must resolve to a String, a @{link String[]} or a Collection<String> where each member of the array or collection is a property name + value with the above formats.

      Returns:
      the properties.
      Default:
      {}
    • concurrency

      String concurrency
      Override the container factory's concurrency setting for this listener. May be a property placeholder or SpEL expression that evaluates to a Number, in which case Number.intValue() is used to obtain the value.

      SpEL #{...} and property placeholders ${...} are supported.

      Returns:
      the concurrency.
      Default:
      ""
    • negativeAckRedeliveryBackoff

      String negativeAckRedeliveryBackoff
      The bean name or a 'SpEL' expression that resolves to a RedeliveryBackoff to use on the consumer to control the redelivery backoff of messages after a negative ack.
      Returns:
      the bean name or empty string to not set the backoff.
      Default:
      ""
    • ackTimeoutRedeliveryBackoff

      String ackTimeoutRedeliveryBackoff
      The bean name or a 'SpEL' expression that resolves to a RedeliveryBackoff to use on the consumer to control the redelivery backoff of messages after an acknowledgment timeout.
      Returns:
      the bean name or empty string to not set the backoff.
      Default:
      ""
    • deadLetterPolicy

      String deadLetterPolicy
      The bean name or a 'SpEL' expression that resolves to a DeadLetterPolicy to use on the consumer to configure a dead letter policy for message redelivery.
      Returns:
      the bean name or empty string to not set any dead letter policy.
      Default:
      ""
    • ackMode

      AckMode ackMode
      Override the container default ack mode of BATCH.
      Returns:
      ack mode used by the listener
      Default:
      BATCH
    • pulsarConsumerErrorHandler

      String pulsarConsumerErrorHandler
      The bean name or a 'SpEL' expression that resolves to a PulsarConsumerErrorHandler which is used as a Spring provided mechanism to handle errors from processing the message.
      Returns:
      the bean name for the consumer error handler or an empty string.
      Default:
      ""