1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.ksb.messaging.serviceproxies;
17
18 import org.kuali.rice.core.api.config.property.ConfigContext;
19 import org.kuali.rice.core.api.util.RiceConstants;
20 import org.kuali.rice.ksb.messaging.MessageServiceInvoker;
21 import org.kuali.rice.ksb.messaging.PersistedMessageBO;
22 import org.kuali.rice.ksb.service.KSBServiceLocator;
23 import org.kuali.rice.ksb.util.KSBConstants;
24 import org.springframework.transaction.support.TransactionSynchronizationManager;
25
26
27
28
29
30
31
32
33
34 public class MessageSender {
35
36 public static void sendMessage(PersistedMessageBO message) throws Exception {
37 if (!Boolean.valueOf(ConfigContext.getCurrentContextConfig().getProperty(KSBConstants.Config.MESSAGING_OFF))) {
38
39 if (ConfigContext.getCurrentContextConfig().getObject(RiceConstants.SPRING_TRANSACTION_MANAGER) != null
40 || ConfigContext.getCurrentContextConfig().getObject(RiceConstants.TRANSACTION_MANAGER_OBJ) != null) {
41 if (TransactionSynchronizationManager.isSynchronizationActive()) {
42 TransactionSynchronizationManager.registerSynchronization(new MessageSendingTransactionSynchronization(
43 message));
44 } else {
45 KSBServiceLocator.getThreadPool().execute(new MessageServiceInvoker(message));
46 }
47 } else {
48 KSBServiceLocator.getThreadPool().execute(new MessageServiceInvoker(message));
49 }
50 }
51 }
52
53 }