public class SchedulerMessageContext extends Object implements MessageContext
MessageContext.| Constructor and Description |
|---|
SchedulerMessageContext(com.atlassian.scheduler.JobRunnerRequest jobRunnerRequest,
String payload,
com.atlassian.scheduler.SchedulerService schedulerService) |
| 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.
|
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. |
boolean |
shouldAutoAcknowledgeMessage() |
public Optional<String> getMessageId()
getMessageId in interface MessageContextpublic Optional<String> getPayload()
getPayload in interface MessageContextpublic void acknowledge()
MessageContextPlease 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.
acknowledge in interface MessageContextpublic boolean isCancellationRequested()
MessageContexttrue 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.
isCancellationRequested in interface MessageContexttrue if cancellation is requested; false otherwisepublic boolean shouldAutoAcknowledgeMessage()
shouldAutoAcknowledgeMessage in interface MessageContexttrue 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.
public void cancelAutoAcknowledgementOfMessage()
MessageContextAuto-acknowledgement occurs after successful completion of MessageRunner.processMessage(MessageContext).
cancelAutoAcknowledgementOfMessage in interface MessageContextCopyright © 2017 Atlassian. All rights reserved.