public class SchedulerMessageRunnerService extends Object implements MessageRunnerService
MessageRunnerService that is backed by the SchedulerService that provides
at-least-once delivery semantics.
When a Message is passed to addMessage(Message), a job is scheduled to run
as-soon-as-possible to process this Message.
When the processing of a Message fails (i.e. MessageRunner.processMessage(MessageContext) throws an exception),
the Message will be delivered up to a total of maxDeliveryCount times at intervals of deliveryIntervalMillis
milliseconds until it is processed successfully. The values of these parameters can be specified when constructing an
instance of this class.
The processing time of a Message can exceed deliveryIntervalMillis. When this happens, re-delivery
of the Message is skipped. Another re-delivery will be attempted after deliveryIntervalMillis milliseconds.
Therefore, only one MessageRunner will be processing a particular Message at any given time.
The processing time of a Message is not currently limited. However long processing times are discouraged.
If a Message fails to be processed successfully after maxDeliveryCount attempts,
a RunDetails instance is recorded to note this occurence. A collection of
RunDetails can be viewed as a dead letter queue.
When constructing an instance of this class with a SchedulerService implementation that supports
persistence of jobs, all Messages passed to addMessage(Message) will be persisted.
To properly initialise an instance of this service, a client must call init() after
constructing an instance (or else ensure the dependency injection framework will automatically invoke methods
annotated with @PostConstruct).
To properly dispose of an instance of this service, a client must call shutdown() (or else ensure the
dependency injection framework will automatically invoke methods annotated with @PreDestroy).
| Constructor and Description |
|---|
SchedulerMessageRunnerService(com.atlassian.scheduler.SchedulerService schedulerService,
MessageRunnerRegistryHelper messageRunnerRegistryHelper,
MessageInformationService messageInformationService,
NestedMessageSerializer nestedMessageSerializer)
Constructs a new instance of SchedulerMessageRunnerService.
|
SchedulerMessageRunnerService(com.atlassian.scheduler.SchedulerService schedulerService,
MessageRunnerRegistryHelper messageRunnerRegistryHelper,
MessageInformationService messageInformationService,
NestedMessageSerializer nestedMessageSerializer,
long deliveryIntervalMillis,
int maxDeliveryCount)
Constructs a new instance of SchedulerMessageRunnerService.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addMessage(Message message)
Adds a message that will be executed at some future point.
|
protected Date |
getFirstDeliveryTime()
Returns message first delivery time.
|
void |
init()
Initialises this instance.
|
void |
shutdown()
Shuts down this instance.
|
public SchedulerMessageRunnerService(com.atlassian.scheduler.SchedulerService schedulerService,
MessageRunnerRegistryHelper messageRunnerRegistryHelper,
MessageInformationService messageInformationService,
NestedMessageSerializer nestedMessageSerializer)
schedulerService - the scheduler servicemessageRunnerRegistryHelper - the message runner registry helpermessageInformationService - message information servicenestedMessageSerializer - the nested message serializerpublic SchedulerMessageRunnerService(com.atlassian.scheduler.SchedulerService schedulerService,
MessageRunnerRegistryHelper messageRunnerRegistryHelper,
MessageInformationService messageInformationService,
NestedMessageSerializer nestedMessageSerializer,
long deliveryIntervalMillis,
int maxDeliveryCount)
schedulerService - the scheduler servicemessageRunnerRegistryHelper - the message runner registry helpermessageInformationService - message information servicenestedMessageSerializer - nested message serializerdeliveryIntervalMillis - the time interval in milliseconds between successive deliveries of a message (must be greater than 0)maxDeliveryCount - the maximum number of times to deliver a message if message processing fails and the message is not acknowledged (must be greater than 0)@PostConstruct public void init()
@PreDestroy public void shutdown()
public void addMessage(Message message)
MessageRunnerServiceaddMessage in interface MessageRunnerServicemessage - message specificationprotected Date getFirstDeliveryTime()
null to delivery as soon as possible; deeper in the past means sooner (higher priority)Copyright © 2017 Atlassian. All rights reserved.