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