1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.ksb.messaging.quartz;
17
18 import org.apache.log4j.Logger;
19 import org.kuali.rice.ksb.messaging.MessageServiceInvoker;
20 import org.kuali.rice.ksb.messaging.PersistedMessageBO;
21 import org.kuali.rice.ksb.messaging.threadpool.KSBThreadPool;
22 import org.kuali.rice.ksb.service.KSBServiceLocator;
23 import org.kuali.rice.ksb.util.KSBConstants;
24 import org.quartz.Job;
25 import org.quartz.JobExecutionContext;
26 import org.quartz.JobExecutionException;
27
28 import java.io.Serializable;
29
30
31
32
33
34
35
36
37
38 public class MessageServiceExecutorJob implements Job, Serializable {
39
40 private static final Logger LOG = Logger.getLogger(MessageServiceExecutorJob.class);
41
42 private static final long serialVersionUID = 6702139047380618522L;
43
44 public static final String MESSAGE_KEY = "message";
45
46 public void execute(JobExecutionContext jec) throws JobExecutionException {
47 try {
48 PersistedMessageBO message = (PersistedMessageBO) jec.getJobDetail().getJobDataMap().get(MESSAGE_KEY);
49 message.setQueueStatus(KSBConstants.ROUTE_QUEUE_ROUTING);
50 KSBServiceLocator.getMessageQueueService().save(message);
51 KSBServiceLocator.getThreadPool().execute(new MessageServiceInvoker(message));
52 } catch (Throwable t) {
53 LOG.error("Caught throwable attempting to process message in exception messaging queue.", t);
54 throw new JobExecutionException(new Exception(t));
55 }
56 }
57 }