public class MessageSubscriptionCreator extends AmqpSubscriptionCreator
Messages. The listener is only registered,
it is not managed any further by this class. To "unregister" either the 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 AmqpSubscriptionCreator.subscribe().
| Modifier and Type | Class and Description |
|---|---|
static interface |
MessageSubscriptionCreator.MessageHandler<M extends Message> |
AmqpSubscriptionCreator.AmqpMessageHandler, AmqpSubscriptionCreator.ReceiptAction| Modifier and Type | Method and Description |
|---|---|
MessageSubscriptionCreator |
forExistingQueue(String queueName)
Configures the listener to be subscribed to an existing queue.
|
MessageSubscriptionCreator |
ignoringMessages(Class<? extends Message>... messageClasses)
Registers the given
Message types to be ignored. |
MessageSubscriptionCreator |
ignoringMessages(Collection<Class<? extends Message>> messageClasses)
Registers the given
Message types to be ignored. |
MessageSubscriptionCreator |
notOlderThan(Duration messageTimeout)
Sets the message timeout.
|
MessageSubscriptionCreator |
notSentAfter(Instant maximumMessageTimestamp)
Sets the maximum timestamp received messages must indicate.
|
MessageSubscriptionCreator |
notSentBefore(AtomicReference<Instant> minimumMessageTimestamp)
Sets the reference to read the minimum timestamp from which received messages must indicate.
|
MessageSubscriptionCreator |
notSentBefore(Instant minimumMessageTimestamp)
Sets the minimum timestamp received messages must indicate.
|
MessageSubscriptionCreator |
onError(AmqpSubscriptionCreator.ReceiptAction receiptAction)
Sets the message receipt to be sent to the AMQP server if an error occurred during message handling.
|
MessageSubscriptionCreator |
onIgnore(AmqpSubscriptionCreator.ReceiptAction receiptAction)
Sets the
ReceiptAction for all ignored messages (filtered by timestamp or message type). |
<M extends Message> |
onMessage(Class<M> messageClass,
MessageSubscriptionCreator.MessageHandler<M> messageHandler)
Registers a
MessageSubscriptionCreator.MessageHandler for the given Message type. |
static MessageSubscriptionCreator |
usingChannel(com.rabbitmq.client.Channel channel)
Instantiates a new
MessageSubscriptionCreator for the given Channel. |
MessageSubscriptionCreator |
withAutoAck(boolean autoAck)
Controls whether all messages should be automatically acknowledged.
|
MessageSubscriptionCreator |
withCryptor(org.vatplanner.commons.crypto.Cryptor cryptor)
Provides a
Cryptor to decrypt messages and verify signatures. |
MessageSubscriptionCreator |
withExchangeParameters(ExchangeParameters exchangeParameters)
Sets the
ExchangeParameters to be used. |
MessageSubscriptionCreator |
withLogPrefix(String logPrefix)
Configures the prefix name to use for all log messages.
|
MessageSubscriptionCreator |
withQueueRoutingKeys(Collection<String> queueRoutingKeys)
Configures the routing keys the queue should be bound to.
|
MessageSubscriptionCreator |
withQueueRoutingKeys(String... queueRoutingKeys)
Configures the routing key(s) the queue should be bound to.
|
onMessage, subscribepublic static MessageSubscriptionCreator usingChannel(com.rabbitmq.client.Channel channel)
MessageSubscriptionCreator for the given Channel.channel - Channel to perform all actions onMessageSubscriptionCreatorpublic MessageSubscriptionCreator withCryptor(org.vatplanner.commons.crypto.Cryptor cryptor)
Cryptor to decrypt messages and verify signatures.cryptor - used for decryption and signature verificationpublic MessageSubscriptionCreator notOlderThan(Duration messageTimeout)
#onIgnore(ReceiptAction).
Note that an additional CLOCK_DRIFT_ALLOWANCE is tolerated to permit slight differences due to all
timestamps referencing local real-time system clocks instead of a uniform network clock.
messageTimeout - maximum age of messages to be processedpublic MessageSubscriptionCreator notSentBefore(Instant minimumMessageTimestamp)
#onIgnore(ReceiptAction). This is different from the
notOlderThan(Duration) timeout which checks the message age compared to time of processing whereas
this minimum timestamp is a fixed absolute point in time.
Note that an additional CLOCK_DRIFT_ALLOWANCE is tolerated to permit slight differences due to all
timestamps referencing local real-time system clocks instead of a uniform network clock.
minimumMessageTimestamp - earliest point in time to accept messages frompublic MessageSubscriptionCreator notSentBefore(AtomicReference<Instant> minimumMessageTimestamp)
#onIgnore(ReceiptAction). This is different from the
notOlderThan(Duration) timeout which checks the message age compared to time of processing whereas
this minimum timestamp is a fixed absolute point in time.
Note that an additional CLOCK_DRIFT_ALLOWANCE is tolerated to permit slight differences due to all
timestamps referencing local real-time system clocks instead of a uniform network clock.
minimumMessageTimestamp - earliest point in time to accept messages frompublic MessageSubscriptionCreator notSentAfter(Instant maximumMessageTimestamp)
#onIgnore(ReceiptAction). This filter only stops further processing but
the listener will continue to receive new messages; the Channel needs to be closed to actually stop
receiving useless messages after the given point in time has been reached.
Note that an additional CLOCK_DRIFT_ALLOWANCE is tolerated to permit slight differences due to all
timestamps referencing local real-time system clocks instead of a uniform network clock.
maximumMessageTimestamp - latest point in time to accept messages frompublic <M extends Message> MessageSubscriptionCreator onMessage(Class<M> messageClass, MessageSubscriptionCreator.MessageHandler<M> messageHandler)
MessageSubscriptionCreator.MessageHandler for the given Message type.@SafeVarargs public final MessageSubscriptionCreator ignoringMessages(Class<? extends Message>... messageClasses)
Message types to be ignored.
This must be set if multiple Message types are expected to be received on the same queue which have no
MessageSubscriptionCreator.MessageHandlers registered as all non-ignored but unhandled messages are treated as errors.
messageClasses - Message types to be ignored if receivedpublic MessageSubscriptionCreator ignoringMessages(Collection<Class<? extends Message>> messageClasses)
Message types to be ignored.
This must be set if multiple Message types are expected to be received on the same queue which have no
MessageSubscriptionCreator.MessageHandlers registered as all non-ignored but unhandled messages are treated as errors.
messageClasses - Message types to be ignored if receivedpublic MessageSubscriptionCreator onIgnore(AmqpSubscriptionCreator.ReceiptAction receiptAction)
ReceiptAction for all ignored messages (filtered by timestamp or message type).receiptAction - action to perform for ignored messagespublic MessageSubscriptionCreator forExistingQueue(String queueName)
AmqpSubscriptionCreatorUsing an existing queue disables queue declaration and does not set up any bindings.
forExistingQueue in class AmqpSubscriptionCreatorqueueName - name of existing queue to be subscribed topublic MessageSubscriptionCreator onError(AmqpSubscriptionCreator.ReceiptAction receiptAction)
AmqpSubscriptionCreatoronError in class AmqpSubscriptionCreatorreceiptAction - message receipt to send in case of errorspublic MessageSubscriptionCreator withAutoAck(boolean autoAck)
AmqpSubscriptionCreator
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.
withAutoAck in class AmqpSubscriptionCreatorautoAck - false disables automated acknowledgements, true (default) enables thempublic MessageSubscriptionCreator withExchangeParameters(ExchangeParameters exchangeParameters)
AmqpSubscriptionCreatorExchangeParameters to be used.withExchangeParameters in class AmqpSubscriptionCreatorexchangeParameters - describes all relevant parameters to declare and bind to the wanted exchangepublic MessageSubscriptionCreator withLogPrefix(String logPrefix)
AmqpSubscriptionCreatorwithLogPrefix in class AmqpSubscriptionCreatorlogPrefix - name to prefix log messages withpublic MessageSubscriptionCreator withQueueRoutingKeys(String... queueRoutingKeys)
AmqpSubscriptionCreatorThis option has no effect if an existing queue will be subscribed to.
withQueueRoutingKeys in class AmqpSubscriptionCreatorqueueRoutingKeys - routing key(s) used to bind queue to exchangepublic MessageSubscriptionCreator withQueueRoutingKeys(Collection<String> queueRoutingKeys)
AmqpSubscriptionCreatorThis option has no effect if an existing queue will be subscribed to.
withQueueRoutingKeys in class AmqpSubscriptionCreatorqueueRoutingKeys - routing keys used to bind queue to exchangeCopyright © 2025. All rights reserved.