public class AmqpSubscriptionCreator extends Object
Channel has to be closed or the
queue (if an existing one was bound) needs to be deleted.
The creator instance must not be modified after subscribe().
| Modifier and Type | Class and Description |
|---|---|
static interface |
AmqpSubscriptionCreator.AmqpMessageHandler
Handles a message received via AMQP.
|
static class |
AmqpSubscriptionCreator.ReceiptAction
Describes how to handle message confirmation on AMQP.
|
| Modifier and Type | Method and Description |
|---|---|
AmqpSubscriptionCreator |
forExistingQueue(String queueName)
Configures the listener to be subscribed to an existing queue.
|
AmqpSubscriptionCreator |
onError(AmqpSubscriptionCreator.ReceiptAction receiptAction)
Sets the message receipt to be sent to the AMQP server if an error occurred during message handling.
|
AmqpSubscriptionCreator |
onMessage(AmqpSubscriptionCreator.AmqpMessageHandler amqpMessageHandler)
Registers the
AmqpSubscriptionCreator.AmqpMessageHandler to process received messages. |
void |
subscribe()
Subscribes to the exchange/queue as previously configured.
|
static AmqpSubscriptionCreator |
usingChannel(com.rabbitmq.client.Channel channel)
Instantiates a new
AmqpSubscriptionCreator for the given Channel. |
AmqpSubscriptionCreator |
withAutoAck(boolean autoAck)
Controls whether all messages should be automatically acknowledged.
|
AmqpSubscriptionCreator |
withExchangeParameters(ExchangeParameters exchangeParameters)
Sets the
ExchangeParameters to be used. |
AmqpSubscriptionCreator |
withLogPrefix(String logPrefix)
Configures the prefix name to use for all log messages.
|
AmqpSubscriptionCreator |
withQueueRoutingKeys(Collection<String> queueRoutingKeys)
Configures the routing keys the queue should be bound to.
|
AmqpSubscriptionCreator |
withQueueRoutingKeys(String... queueRoutingKeys)
Configures the routing key(s) the queue should be bound to.
|
public static AmqpSubscriptionCreator usingChannel(com.rabbitmq.client.Channel channel)
AmqpSubscriptionCreator for the given Channel.channel - Channel to perform all actions onAmqpSubscriptionCreatorpublic AmqpSubscriptionCreator onError(AmqpSubscriptionCreator.ReceiptAction receiptAction)
receiptAction - message receipt to send in case of errorspublic AmqpSubscriptionCreator forExistingQueue(String queueName)
Using an existing queue disables queue declaration and does not set up any bindings.
queueName - name of existing queue to be subscribed topublic AmqpSubscriptionCreator withQueueRoutingKeys(String... queueRoutingKeys)
This option has no effect if an existing queue will be subscribed to.
queueRoutingKeys - routing key(s) used to bind queue to exchangepublic AmqpSubscriptionCreator withQueueRoutingKeys(Collection<String> queueRoutingKeys)
This option has no effect if an existing queue will be subscribed to.
queueRoutingKeys - routing keys used to bind queue to exchangepublic AmqpSubscriptionCreator withLogPrefix(String logPrefix)
logPrefix - name to prefix log messages withpublic AmqpSubscriptionCreator withExchangeParameters(ExchangeParameters exchangeParameters)
ExchangeParameters to be used.exchangeParameters - describes all relevant parameters to declare and bind to the wanted exchangepublic AmqpSubscriptionCreator withAutoAck(boolean autoAck)
See AMQP server/protocol for exact details but generally automated acknowledgments will be issued immediately
when a message has been sent which can happen even before the message ever reaches any handling implementations.
The majority of messages usually do not require explicit message confirmation, so auto-ack is enabled by default.
In order to be able to perform any AmqpSubscriptionCreator.ReceiptActions to indicate actual message handling or errors to the
AMQP server, auto-ack needs to be disabled.
autoAck - false disables automated acknowledgements, true (default) enables thempublic AmqpSubscriptionCreator onMessage(AmqpSubscriptionCreator.AmqpMessageHandler amqpMessageHandler)
AmqpSubscriptionCreator.AmqpMessageHandler to process received messages.amqpMessageHandler - will be called for all received messagespublic void subscribe()
This is a terminal operation; this instance must not be altered or reused following this method call.
Copyright © 2025. All rights reserved.