Interface ConsumerBuilder
Consumer
.-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interface
Auto-tracking strategy.static interface
Filter configuration.static interface
Message flow configuration.static interface
Manual tracking strategy. -
Method Summary
Modifier and TypeMethodDescriptionbuild()
Create the configuredConsumer
consumerUpdateListener
(ConsumerUpdateListener consumerUpdateListener) Set the listener for single active consumer updates.filter()
Configure the filtering.flow()
Configure flow of messages.listeners
(Resource.StateListener... listeners) AddResource.StateListener
s to the consumer.messageHandler
(MessageHandler messageHandler) The callback for inbound messages.The logical name of theConsumer
.Disable server-side offset tracking.offset
(OffsetSpecification offsetSpecification) The offset to start consuming from.Declare the consumer as a single active consumer.The stream to consume from.subscriptionListener
(SubscriptionListener subscriptionListener) Callback on subscription.superStream
(String superStream) Set the consumer to consume from a super stream (partitioned stream).
-
Method Details
-
stream
The stream to consume from.- Parameters:
stream
-- Returns:
- this builder instance
-
superStream
Set the consumer to consume from a super stream (partitioned stream).This is meant to be used with
singleActiveConsumer()
.This is an experimental API, subject to change.
RabbitMQ 3.11 or more is required.
- Parameters:
superStream
-- Returns:
- this builder instance
- See Also:
-
offset
The offset to start consuming from.The default is
OffsetSpecification.next()
(the end of the stream).- Parameters:
offsetSpecification
-- Returns:
- this builder instance
-
messageHandler
The callback for inbound messages.- Parameters:
messageHandler
-- Returns:
- this builder instance
-
name
The logical name of theConsumer
.Set a logical name to enable offset tracking.
- Parameters:
name
-- Returns:
- this builder instance
-
singleActiveConsumer
ConsumerBuilder singleActiveConsumer()Declare the consumer as a single active consumer.A single active consumer must set up a name with
name(String)
.Instances of the same application can declare several single active consumer instances with the same name and only one will be active at a time, meaning it will be the only one to get messages from the broker.
If the active consumer instance stops or crashes, the broker will choose a new active instance among the remaining ones.
This is an experimental API, subject to change.
RabbitMQ 3.11 or more is required.
- Returns:
- this builder instance
- Since:
- 0.6.0
- See Also:
-
consumerUpdateListener
Set the listener for single active consumer updates.This listener is usually set when manual offset tracking is used, either server-side or with an external datastore.
This is an experimental API, subject to change.
RabbitMQ 3.11 or more is required.
- Parameters:
consumerUpdateListener
-- Returns:
- this builder instance
- Since:
- 0.6.0
- See Also:
-
subscriptionListener
Callback on subscription.Can be used to set the offset specification before subscribing to the stream.
This is an experimental API, subject to change.
- Parameters:
subscriptionListener
- the listener- Returns:
- this builder instance
- Since:
- 0.5.0
- See Also:
-
listeners
AddResource.StateListener
s to the consumer.A consumer uses one connection for consuming and another connection for server-side offset tracking (if activated by setting a name with
name(String)
). AResource.StateListener
receives state updates for both connections, so a consumer can still be consuming messages after it receives aResource.State.RECOVERING
state update, as the update may be related to the offset tracking connection.- Parameters:
listeners
- listeners- Returns:
- this builder instance
- Since:
- 1.3.0
-
manualTrackingStrategy
ConsumerBuilder.ManualTrackingStrategy manualTrackingStrategy()- Returns:
- the manual tracking strategy
-
autoTrackingStrategy
ConsumerBuilder.AutoTrackingStrategy autoTrackingStrategy()EnableConsumerBuilder.AutoTrackingStrategy
.This is the default tracking strategy.
- Returns:
- the auto-tracking strategy
-
noTrackingStrategy
ConsumerBuilder noTrackingStrategy()Disable server-side offset tracking.Useful when
singleActiveConsumer()
is enabled and an external store is used for offset tracking. This avoids automatic server-side offset tracking to kick in.- Returns:
- this builder instance
- Since:
- 0.6.0
-
filter
ConsumerBuilder.FilterConfiguration filter()Configure the filtering.RabbitMQ 3.13 or more is required.
- Returns:
- the filtering configuration
-
flow
Configure flow of messages.- Returns:
- the flow configuration
- Since:
- 0.11.0
- See Also:
-
build
Consumer build()Create the configuredConsumer
- Returns:
- the configured consumer
-