1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
package org.kuali.rice.ksb.messaging.quartz; |
14 | |
|
15 | |
import org.apache.log4j.Logger; |
16 | |
import org.kuali.rice.ksb.messaging.MessageServiceInvoker; |
17 | |
import org.kuali.rice.ksb.messaging.PersistedMessageBO; |
18 | |
import org.kuali.rice.ksb.messaging.threadpool.KSBThreadPool; |
19 | |
import org.kuali.rice.ksb.service.KSBServiceLocator; |
20 | |
import org.kuali.rice.ksb.util.KSBConstants; |
21 | |
import org.quartz.Job; |
22 | |
import org.quartz.JobExecutionContext; |
23 | |
import org.quartz.JobExecutionException; |
24 | |
|
25 | |
import java.io.Serializable; |
26 | |
|
27 | |
|
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | 0 | public class MessageServiceExecutorJob implements Job, Serializable { |
36 | |
|
37 | 0 | 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 | 0 | PersistedMessageBO message = (PersistedMessageBO) jec.getJobDetail().getJobDataMap().get(MESSAGE_KEY); |
46 | 0 | message.setQueueStatus(KSBConstants.ROUTE_QUEUE_ROUTING); |
47 | 0 | KSBServiceLocator.getMessageQueueService().save(message); |
48 | 0 | KSBServiceLocator.getThreadPool().execute(new MessageServiceInvoker(message)); |
49 | 0 | } catch (Throwable t) { |
50 | 0 | LOG.error("Caught throwable attempting to process message in exception messaging queue.", t); |
51 | 0 | throw new JobExecutionException(new Exception(t)); |
52 | 0 | } |
53 | 0 | } |
54 | |
} |