Package io.micronaut.pulsar.annotation
Annotation Interface PulsarConsumer
@Documented
@Retention(RUNTIME)
@Target(METHOD)
@Executable
@MessageListener
public @interface PulsarConsumer
Marks a method as a Pulsar Consumer.
- Since:
- 1.0
- Author:
- Haris Secic
-
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionBy default, it will use default value ofConsumerBuilderwhich is disabled and no redelivery happens unless consumer crashed.Default is fallback to Pulsar Client Java library.org.apache.pulsar.common.schema.KeyValueEncodingTypeIgnored if annotated method does not contain parameter annotated withMessageKey.Ignored ifkeyEncoding()isKeyValueEncodingType.INLINEor ifMessageKeyis missing on one of the attributes of the annotated method.intintUsed in combination withtopicsPattern().intBy default, no priority is set.intbooleanBy default, consumer should subscribe in non-blocking manner using defaultCompletableFutureofConsumerBuilder.subscribeAsync().org.apache.pulsar.client.api.RegexSubscriptionModeIgnored iftopics()attribute is set.org.apache.pulsar.client.api.SubscriptionTypeHas precedence overtopics()andtopicsPattern().String[]Has precedence overtopicPattern.Ignored iftopicsattribute is set.
-
Element Details
-
value
@AliasFor(member="topic") @AliasFor(annotation=io.micronaut.messaging.annotation.MessageMapping.class,member="value") String value- Returns:
- Same as
topic()
- Default:
- ""
-
topic
@AliasFor(member="value") @AliasFor(annotation=io.micronaut.messaging.annotation.MessageMapping.class,member="value") String topicHas precedence overtopics()andtopicsPattern(). Single topic to consume messages from.- Returns:
- Topic name to listen to
- Default:
- ""
-
topics
@AliasFor(annotation=io.micronaut.messaging.annotation.MessageMapping.class, member="value") String[] topicsHas precedence overtopicPattern.- Returns:
- String[] of topic names in form of (persistent|non-persistent)://tenant-name/namespace/topic.
- Default:
- {}
-
topicsPattern
@AliasFor(annotation=io.micronaut.messaging.annotation.MessageMapping.class, member="value") String topicsPatternIgnored iftopicsattribute is set.- Returns:
- Topics name in form of tenantName/namespace/topic-name-pattern.
- Default:
- ""
-
schema
MessageSchema schema- Returns:
- Schema to use with pulsar topic consumer
- Default:
- BYTES
-
keySchema
MessageSchema keySchemaIgnored ifkeyEncoding()isKeyValueEncodingType.INLINEor ifMessageKeyis missing on one of the attributes of the annotated method.- Returns:
- Schema to use while parsing message key from Pulsar message
- Default:
- BYTES
-
keyEncoding
org.apache.pulsar.common.schema.KeyValueEncodingType keyEncodingIgnored if annotated method does not contain parameter annotated withMessageKey. Indicates to message processor is the key inside message payload or stored separately in which case key can have different schema from message body. TypeKeyValueEncodingType.INLINEcan only work for JSON or Avro schemas; otherwise throws exception while reading.- Returns:
- Whether to read key from the message payload or separately.
- Default:
- INLINE
-
consumerName
String consumerName- Returns:
- Consumer name for more descriptive monitoring
- Default:
- ""
-
subscription
String subscription- Returns:
- Subscription name in case consumer was defined outside the
PulsarSubscriptionannotated class
- Default:
- ""
-
subscriptionType
org.apache.pulsar.client.api.SubscriptionType subscriptionType- Returns:
- Subscription type in case consumer was defined outside of
PulsarSubscriptionannotated class
- Default:
- Exclusive
-
subscriptionTopicsMode
org.apache.pulsar.client.api.RegexSubscriptionMode subscriptionTopicsModeIgnored iftopics()attribute is set. Default valueRegexSubscriptionMode.AllTopicsWhether to read topics from persistent, or non-persistent storage, or both.
- Returns:
- subscription
- Default:
- AllTopics
-
patternAutoDiscoveryPeriod
int patternAutoDiscoveryPeriodUsed in combination withtopicsPattern(). Ignored usingtopics(). Must be greater than 1. Low values should be avoided. Pulsar default value is 1 minute- Returns:
- Amount of delay between checks, in seconds, for new topic matching given pattern.
- Default:
- -1
-
subscribeAsync
boolean subscribeAsyncBy default, consumer should subscribe in non-blocking manner using defaultCompletableFutureofConsumerBuilder.subscribeAsync().If blocking set to false application will block until consumer is successfully subscribed. This is different from the actual process of consuming the messages which still happens in separate thread managed by the underlying Pulsar Client library.
- Returns:
- Should the consumer subscribe in async manner or blocking
- Default:
- true
-
ackTimeout
String ackTimeoutBy default, it will use default value ofConsumerBuilderwhich is disabled and no redelivery happens unless consumer crashed.Must be greater than 1s.
- Returns:
- Allowed time to pass before message is acknowledged.
- See Also:
-
ConsumerBuilder.ackTimeout(long, java.util.concurrent.TimeUnit)
- Default:
- ""
-
receiverQueueSize
int receiverQueueSize- Returns:
- Number of items allowed in the queue. Default 1000 as in Pulsar Java Client
- Default:
- 1000
-
priorityLevel
int priorityLevelBy default, no priority is set. Use any value less than 0 to disable. Use anything above 0 to set lower priority level.- Returns:
- priority level for a consumer
- See Also:
-
ConsumerBuilder.priorityLevel(int)
- Default:
- -1
-
deadLetterTopic
String deadLetterTopicDefault is fallback to Pulsar Client Java library.- Returns:
- Dead Letter topic name.
- Default:
- ""
-
maxRetriesBeforeDlq
int maxRetriesBeforeDlq- Returns:
- Maximum numbers of retires before sending message to dead letter queue topic.
- Default:
- 16
-