Interface Consumer
- All Superinterfaces:
AutoCloseable, Resource
API to consume messages from a RabbitMQ queue.
Instances are configured and created with a ConsumerBuilder.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceContext to accumulate message contexts and settle them at once.static interfaceContext for message processing.static interfaceContract to process a message.Nested classes/interfaces inherited from interface Resource
Resource.State, Resource.StateListener -
Method Summary
Modifier and TypeMethodDescriptionvoidclaimDeferred(String... tokens) Claim messages previously deferred with aConsumer.Context.defer(String, java.time.Duration)token, so they are redelivered ahead of their scheduled delivery time.voidclose()Close the consumer with its resources.voidpause()Pause the consumer to stop receiving messages.voidunpause()Request to receive messages again.longReturn the number of unsettled messages.
-
Method Details
-
pause
void pause()Pause the consumer to stop receiving messages.Messages already in flight when this method is called may still be delivered after it returns.
- Throws:
AmqpException- if the consumer is not open
-
unsettledMessageCount
long unsettledMessageCount()Return the number of unsettled messages.- Returns:
- unsettled message count
-
unpause
void unpause()Request to receive messages again.- Throws:
AmqpException- if the consumer is not open
-
close
-
claimDeferred
Claim messages previously deferred with aConsumer.Context.defer(String, java.time.Duration)token, so they are redelivered ahead of their scheduled delivery time.A token may have been used for more than one message, in which case claiming it can deliver more than one message, oldest first. Claiming an unknown token has no effect: it is silently ignored by the broker. A claim does not grant extra credit: claimed messages are delivered as the consumer's existing credit allows.
Claims do not survive connection recovery: the application must claim tokens again after the consumer recovers.
Only quorum queues support deferral tokens.
Requires RabbitMQ 4.4 or more.
This is an experimental API, subject to change.
- Parameters:
tokens- the tokens to claim- Throws:
AmqpException- if the consumer is not openAmqpException- if the queue this consumer is attached to does not support deferral tokens- Since:
- 1.7.0
- See Also:
-