org.kuali.rice.kcb.quartz
Class MessageProcessingJob

java.lang.Object
  extended by org.kuali.rice.kcb.quartz.ConcurrentJob<MessageDelivery>
      extended by 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
static class MessageProcessingJob.Mode
           
 
Field Summary
static String GROUP
           
static String NAME
           
 
Fields inherited from class org.kuali.rice.kcb.quartz.ConcurrentJob
executor, txManager
 
Constructor Summary
MessageProcessingJob()
           
MessageProcessingJob(Long messageId, MessageProcessingJob.Mode mode, String user, String cause)
           
 
Method Summary
protected  Collection<MessageDelivery> bulkProcess(BulkMessageDeliverer messageDeliverer, Collection<MessageDelivery> messageDeliveries, MessageProcessingJob.Mode mode)
          Implements bulk delivery of a collection of MessageDeliverys
 void execute(org.quartz.JobExecutionContext context)
           
protected  void finishProcessing(ProcessingResult<MessageDelivery> result)
          Template method called after processing of work items has completed
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
protected  Collection<MessageDelivery> process(MessageDeliverer messageDeliverer, MessageDelivery messageDelivery, MessageProcessingJob.Mode mode)
          Implements delivery of a single MessageDelivery
protected  Collection<MessageDelivery> processWorkItems(Collection<MessageDelivery> messageDeliveries)
          Template method that subclasses should override to process a given work item and mark it as untaken afterwards
 ProcessingResult<MessageDelivery> run()
          Main processing method which invokes subclass implementations of template methods to obtain available work items, and process them concurrently
 void setGenericDao(GenericDao dao)
          Sets the GenericDao
 void setMessageDelivererRegistry(MessageDelivererRegistryService registry)
          Sets the MessageDelivererRegistryService
 void setMessageDeliveryService(MessageDeliveryService messageDeliveryService)
          Sets the MessageDeliveryService
protected  Collection<MessageDelivery> takeAvailableWorkItems()
          Template method that subclasses should override to obtain a set of available work items and mark them as taken
protected  void unlockWorkItem(MessageDelivery item)
          Template method that subclasses should override to unlock a given work item when procesing has failed.
protected  void updateStatusAndUnlock(MessageDelivery messageDelivery, MessageDeliveryStatus status)
          Marks a MessageDelivery as having been delivered, and unlocks it
 
Methods inherited from class org.kuali.rice.kcb.quartz.ConcurrentJob
createNewTransaction, executeInTransaction, setExecutorService, setTransactionManager, unlockWorkItemAtomically
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NAME

public static final String NAME
See Also:
Constant Field Values

GROUP

public static final String GROUP
See Also:
Constant Field Values
Constructor Detail

MessageProcessingJob

public MessageProcessingJob(Long messageId,
                            MessageProcessingJob.Mode mode,
                            String user,
                            String cause)

MessageProcessingJob

public MessageProcessingJob()
Method Detail

setGenericDao

public void setGenericDao(GenericDao dao)
Sets the GenericDao

Parameters:
dao - the GenericDao

setMessageDelivererRegistry

public void setMessageDelivererRegistry(MessageDelivererRegistryService registry)
Sets the MessageDelivererRegistryService

Parameters:
registry - the MessageDelivererRegistryService

setMessageDeliveryService

public void setMessageDeliveryService(MessageDeliveryService messageDeliveryService)
Sets the MessageDeliveryService

Parameters:
messageDeliveryService - the MessageDeliveryService

takeAvailableWorkItems

protected Collection<MessageDelivery> takeAvailableWorkItems()
Description copied from class: ConcurrentJob
Template method that subclasses should override to obtain a set of available work items and mark them as taken

Specified by:
takeAvailableWorkItems in class ConcurrentJob<MessageDelivery>
Returns:
a collection of available work items that have been marked as taken

unlockWorkItem

protected void unlockWorkItem(MessageDelivery item)
Description copied from class: ConcurrentJob
Template method that subclasses should override to unlock a given work item when procesing has failed.

Specified by:
unlockWorkItem in class ConcurrentJob<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:
groupWorkItems in class ConcurrentJob<MessageDelivery>
Parameters:
workItems - list of work items to break into groups
result - 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:
org.kuali.rice.ken.service.impl.ConcurrentJob#groupWorkItems(java.util.Collection)

processWorkItems

protected Collection<MessageDelivery> processWorkItems(Collection<MessageDelivery> messageDeliveries)
Description copied from class: ConcurrentJob
Template method that subclasses should override to process a given work item and mark it as untaken afterwards

Specified by:
processWorkItems in class ConcurrentJob<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:
deliverer - the deliverer
messageDelivery - 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 of MessageDeliverys

Parameters:
deliverer - the deliverer
messageDeliveries - the deliveries
Returns:
collection of strings indicating successful deliveries

finishProcessing

protected void finishProcessing(ProcessingResult<MessageDelivery> result)
Description copied from class: ConcurrentJob
Template method called after processing of work items has completed

Overrides:
finishProcessing in class ConcurrentJob<MessageDelivery>

updateStatusAndUnlock

protected void updateStatusAndUnlock(MessageDelivery messageDelivery,
                                     MessageDeliveryStatus status)
Marks a MessageDelivery as having been delivered, and unlocks it

Parameters:
messageDelivery - the messageDelivery instance to mark

run

public ProcessingResult<MessageDelivery> run()
Description copied from class: ConcurrentJob
Main processing method which invokes subclass implementations of template methods to obtain available work items, and process them concurrently

Overrides:
run in class ConcurrentJob<MessageDelivery>
Returns:
a ProcessingResult object containing the results of processing

execute

public void execute(org.quartz.JobExecutionContext context)
             throws org.quartz.JobExecutionException
Specified by:
execute in interface org.quartz.Job
Throws:
org.quartz.JobExecutionException


Copyright © 2005-2013 The Kuali Foundation. All Rights Reserved.