@PublicApi
public interface MessageContext
| Modifier and Type | Method and Description |
|---|---|
void |
acknowledge()
Called by a message consumer to acknowledge the receipt of a message and prevent it's redelivery to another consumer.
|
default void |
cancelAutoAcknowledgementOfMessage()
Cancels the auto-acknowledgement of the message in this context.
|
Optional<String> |
getMessageId() |
Optional<String> |
getPayload() |
boolean |
isCancellationRequested()
Returns
true if the MessageRunner should terminate its activities as gracefully as possible
and exit; false to continue running normally. |
default boolean |
shouldAutoAcknowledgeMessage() |
Optional<String> getPayload()
void acknowledge()
Please note: due to the distributed nature of how messages are stored in some implementations, there are no guarantees that the message won't be redelivered to another consumer (even after this method is called). However, redelivery after acknowledge() is rare.
This method is thread-safe and idempotent.
MessageAcknowledgementException - if there is an error in acknowledgement.boolean isCancellationRequested()
true if the MessageRunner should terminate its activities as gracefully as possible
and exit; false to continue running normally.
MessageRunner cancellation is entirely cooperative. If a MessageRunner is likely to take longer
than a few seconds to complete its work, then it should periodically check this value and react to it. Normally,
cancellation is requested because the application is trying to shut down, and continuing to run
after this flag has been set increases the chance that the system administrator will grow
impatient and forcibly kill the application.
true if cancellation is requested; false otherwisedefault boolean shouldAutoAcknowledgeMessage()
true if the message in this context should automatically be acknowledged after successful
completion of MessageRunner.processMessage(MessageContext). If
MessageRunner.processMessage(MessageContext) throws an exception, the message won't be acknowledged and
will be redelivered after a delay (assuming the delivery count of the message has not exceeded the maximum count
configured).
Returns false if the message should not be automatically acknowledged on successful completion.
default void cancelAutoAcknowledgementOfMessage()
Auto-acknowledgement occurs after successful completion of MessageRunner.processMessage(MessageContext).
Copyright © 2017 Atlassian. All rights reserved.