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