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 | 0 | public class MessageSender { |
35 | |
|
36 | |
public static void sendMessage(PersistedMessageBO message) throws Exception { |
37 | 0 | if (!Boolean.valueOf(ConfigContext.getCurrentContextConfig().getProperty(KSBConstants.Config.MESSAGING_OFF))) { |
38 | |
|
39 | 0 | if (ConfigContext.getCurrentContextConfig().getObject(RiceConstants.SPRING_TRANSACTION_MANAGER) != null |
40 | |
|| ConfigContext.getCurrentContextConfig().getObject(RiceConstants.TRANSACTION_MANAGER_OBJ) != null) { |
41 | 0 | if (TransactionSynchronizationManager.isSynchronizationActive()) { |
42 | 0 | TransactionSynchronizationManager.registerSynchronization(new MessageSendingTransactionSynchronization( |
43 | |
message)); |
44 | |
} else { |
45 | 0 | KSBServiceLocator.getThreadPool().execute(new MessageServiceInvoker(message)); |
46 | |
} |
47 | |
} else { |
48 | 0 | KSBServiceLocator.getThreadPool().execute(new MessageServiceInvoker(message)); |
49 | |
} |
50 | |
} |
51 | 0 | } |
52 | |
|
53 | |
} |