Package org.kuali.rice.kcb.quartz
Class MessageProcessingJob
java.lang.Object
org.kuali.rice.kcb.quartz.ConcurrentJob<MessageDelivery>
org.kuali.rice.kcb.quartz.MessageProcessingJob
- All Implemented Interfaces:
org.quartz.Job,org.quartz.StatefulJob
public class MessageProcessingJob
extends ConcurrentJob<MessageDelivery>
implements org.quartz.StatefulJob
Job that delivers messages to endpoints. This job is not really stateful,
but should not be executed concurrently.
- Author:
- Kuali Rice Team (rice.collab@kuali.org)
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsFields inherited from class org.kuali.rice.kcb.quartz.ConcurrentJob
executor, txManager -
Constructor Summary
ConstructorsConstructorDescriptionMessageProcessingJob(Long messageId, MessageProcessingJob.Mode mode, String user, String cause) -
Method Summary
Modifier and TypeMethodDescriptionprotected Collection<MessageDelivery> bulkProcess(BulkMessageDeliverer messageDeliverer, Collection<MessageDelivery> messageDeliveries, MessageProcessingJob.Mode mode) Implements bulk delivery of a collection ofMessageDeliverysvoidexecute(org.quartz.JobExecutionContext context) protected voidTemplate method called after processing of work items has completedprotected Collection<Collection<MessageDelivery>> groupWorkItems(Collection<MessageDelivery> workItems, ProcessingResult<MessageDelivery> result) Group work items by deliverer and notification, so that deliveries to bulk deliverers are grouped by notificationprotected Collection<MessageDelivery> process(MessageDeliverer messageDeliverer, MessageDelivery messageDelivery, MessageProcessingJob.Mode mode) Implements delivery of a single MessageDeliveryprotected Collection<MessageDelivery> processWorkItems(Collection<MessageDelivery> messageDeliveries) Template method that subclasses should override to process a given work item and mark it as untaken afterwardsrun()Main processing method which invokes subclass implementations of template methods to obtain available work items, and process them concurrentlyvoidsetDataObjectService(DataObjectService dataObjectService) Sets theDataObjectServicevoidSets theMessageDelivererRegistryServicevoidsetMessageDeliveryService(MessageDeliveryService messageDeliveryService) Sets theMessageDeliveryServiceprotected Collection<MessageDelivery> Template method that subclasses should override to obtain a set of available work items and mark them as takenprotected voidTemplate method that subclasses should override to unlock a given work item when procesing has failed.protected voidupdateStatusAndUnlock(MessageDelivery messageDelivery, MessageDeliveryStatus status) Marks a MessageDelivery as having been delivered, and unlocks itMethods inherited from class org.kuali.rice.kcb.quartz.ConcurrentJob
createNewTransaction, executeInTransaction, setExecutorService, setTransactionManager, unlockWorkItemAtomically
-
Field Details
-
NAME
- See Also:
-
GROUP
- See Also:
-
-
Constructor Details
-
MessageProcessingJob
public MessageProcessingJob(Long messageId, MessageProcessingJob.Mode mode, String user, String cause) -
MessageProcessingJob
public MessageProcessingJob()
-
-
Method Details
-
setDataObjectService
Sets theDataObjectService- Parameters:
dataObjectService- theDataObjectService
-
setMessageDelivererRegistry
Sets theMessageDelivererRegistryService- Parameters:
registry- theMessageDelivererRegistryService
-
setMessageDeliveryService
Sets theMessageDeliveryService- Parameters:
messageDeliveryService- theMessageDeliveryService
-
takeAvailableWorkItems
Description copied from class:ConcurrentJobTemplate method that subclasses should override to obtain a set of available work items and mark them as taken- Specified by:
takeAvailableWorkItemsin classConcurrentJob<MessageDelivery>- Returns:
- a collection of available work items that have been marked as taken
-
unlockWorkItem
Description copied from class:ConcurrentJobTemplate method that subclasses should override to unlock a given work item when procesing has failed.- Specified by:
unlockWorkItemin classConcurrentJob<MessageDelivery>- Parameters:
item- the work item to unlock
-
groupWorkItems
protected Collection<Collection<MessageDelivery>> groupWorkItems(Collection<MessageDelivery> workItems, ProcessingResult<MessageDelivery> result) Group work items by deliverer and notification, so that deliveries to bulk deliverers are grouped by notification- Overrides:
groupWorkItemsin classConcurrentJob<MessageDelivery>- Parameters:
workItems- list of work items to break into groupsresult- ProcessingResult to modify if there are any failures...this is sort of a hack because previously failure to obtain a deliverer was considered a work item failure, and now this method has been factored out... but the tests still want to see the failure- Returns:
- a collection of collection of work items
- See Also:
-
processWorkItems
protected Collection<MessageDelivery> processWorkItems(Collection<MessageDelivery> messageDeliveries) Description copied from class:ConcurrentJobTemplate method that subclasses should override to process a given work item and mark it as untaken afterwards- Specified by:
processWorkItemsin classConcurrentJob<MessageDelivery>- Returns:
- a collection of success messages
-
process
protected Collection<MessageDelivery> process(MessageDeliverer messageDeliverer, MessageDelivery messageDelivery, MessageProcessingJob.Mode mode) Implements delivery of a single MessageDelivery- Parameters:
messageDeliverer- the deliverermessageDelivery- the delivery- Returns:
- collection of strings indicating successful deliveries
-
bulkProcess
protected Collection<MessageDelivery> bulkProcess(BulkMessageDeliverer messageDeliverer, Collection<MessageDelivery> messageDeliveries, MessageProcessingJob.Mode mode) Implements bulk delivery of a collection ofMessageDeliverys- Parameters:
messageDeliverer- the deliverermessageDeliveries- the deliveries- Returns:
- collection of strings indicating successful deliveries
-
finishProcessing
Description copied from class:ConcurrentJobTemplate method called after processing of work items has completed- Overrides:
finishProcessingin classConcurrentJob<MessageDelivery>
-
updateStatusAndUnlock
Marks a MessageDelivery as having been delivered, and unlocks it- Parameters:
messageDelivery- the messageDelivery instance to mark
-
run
Description copied from class:ConcurrentJobMain processing method which invokes subclass implementations of template methods to obtain available work items, and process them concurrently- Overrides:
runin classConcurrentJob<MessageDelivery>- Returns:
- a ProcessingResult object containing the results of processing
-
execute
public void execute(org.quartz.JobExecutionContext context) throws org.quartz.JobExecutionException - Specified by:
executein interfaceorg.quartz.Job- Throws:
org.quartz.JobExecutionException
-