Annotation Interface PulsarListener
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
Modifier and TypeOptional ElementDescriptionOverride the container default ack mode of BATCH.The bean name or a SpEL expression that resolves to aRedeliveryBackoff
to use on the consumer to control the redelivery backoff of messages after an acknowledgment timeout.Whether to automatically start the container for this listener.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'sconcurrency
setting for this listener.The bean name or a SpEL expression that resolves to aPulsarListenerConsumerBuilderCustomizer
to use to configure the underlying consumer.The bean name of thePulsarListenerContainerFactory
to use to create the message listener container responsible to serve this endpoint.The bean name or a SpEL expression that resolves to aDeadLetterPolicy
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 aRedeliveryBackoff
to use on the consumer to control the redelivery backoff of messages after a negative ack.String[]
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 aPulsarConsumerErrorHandler
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 - expected to be a single element array with subscription type or empty array to indicate null type.Topic patten to listen to.String[]
Topics to listen to.
-
Element Details
-
id
String idThe unique identifier of the container for this listener.If none is specified an auto-generated id is used.
SpEL
#{...}
and property placeholders${...}
are supported.- Returns:
- the
id
for the container managing for this endpoint. - See Also:
- Default:
- ""
-
subscriptionName
String subscriptionNamePulsar subscription name associated with this listener.SpEL
#{...}
and property placeholders${...}
are supported.- Returns:
- the subscription name for this listener
- Default:
- ""
-
subscriptionType
org.apache.pulsar.client.api.SubscriptionType[] subscriptionTypePulsar subscription type for this listener - expected to be a single element array with subscription type or empty array to indicate null type.- Returns:
- single element array with the subscription type or empty array to indicate no type chosen by user
- Default:
- {Exclusive}
-
schemaType
org.apache.pulsar.common.schema.SchemaType schemaTypePulsar schema type for this listener.- Returns:
- the
schemaType
for this listener
- Default:
- NONE
-
containerFactory
String containerFactoryThe bean name of thePulsarListenerContainerFactory
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[] topicsTopics to listen to.SpEL
#{...}
and property placeholders${...}
are supported.- Returns:
- an array of topics to listen to
- Default:
- {}
-
topicPattern
String topicPatternTopic patten to listen to.SpEL
#{...}
and property placeholders${...}
are supported.- Returns:
- topic pattern to listen to
- Default:
- ""
-
autoStartup
String autoStartupWhether to automatically start the container for this listener.The value can be a literal string representation of boolean (e.g.
'true'
) or a property placeholder${...}
that resolves to a literal. SpEL#{...}
expressions that evaluate to aBoolean
or a literal are supported.- Returns:
- whether to automatically start the container for this listener
- Default:
- ""
-
batch
boolean batchActivate batch consumption.- Returns:
- whether this listener is in batch mode or not.
- Default:
- false
-
beanRef
String beanRefA 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[] propertiesPulsar 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
andclient.id
are ignored.SpEL
#{...}
and property placeholders${...}
are supported. SpEL expressions must resolve to aString
, a @{link String[]} or aCollection<String>
where each member of the array or collection is a property name + value with the above formats.- Returns:
- the properties.
- Default:
- {}
-
concurrency
String concurrencyOverride the container factory'sconcurrency
setting for this listener.The value can be a literal string representation of
Number
(e.g.'3'
) or a property placeholder${...}
that resolves to a literal. SpEL#{...}
expressions that evaluate to aNumber
or a literal are supported.- Returns:
- the concurrency for this listener
- Default:
- ""
-
negativeAckRedeliveryBackoff
String negativeAckRedeliveryBackoffThe bean name or a SpEL expression that resolves to aRedeliveryBackoff
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 ackTimeoutRedeliveryBackoffThe bean name or a SpEL expression that resolves to aRedeliveryBackoff
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 deadLetterPolicyThe bean name or a SpEL expression that resolves to aDeadLetterPolicy
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 ackModeOverride the container default ack mode of BATCH.- Returns:
- ack mode used by the listener
- Default:
- BATCH
-
pulsarConsumerErrorHandler
String pulsarConsumerErrorHandlerThe bean name or a SpEL expression that resolves to aPulsarConsumerErrorHandler
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:
- ""
-
consumerCustomizer
String consumerCustomizerThe bean name or a SpEL expression that resolves to aPulsarListenerConsumerBuilderCustomizer
to use to configure the underlying consumer.- Returns:
- the bean name or SpEL expression to the customizer or an empty string to not customize the consumer
- Default:
- ""
-