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.apache.log4j.Logger; |
19 | |
import org.kuali.rice.ksb.messaging.MessageServiceInvoker; |
20 | |
import org.kuali.rice.ksb.messaging.PersistedMessageBO; |
21 | |
import org.kuali.rice.ksb.service.KSBServiceLocator; |
22 | |
import org.springframework.transaction.support.TransactionSynchronization; |
23 | |
|
24 | |
|
25 | |
|
26 | |
|
27 | |
|
28 | |
|
29 | |
|
30 | |
|
31 | |
public class MessageSendingTransactionSynchronization implements TransactionSynchronization { |
32 | |
|
33 | 0 | private static final Logger LOG = Logger.getLogger(MessageSendingTransactionSynchronization.class); |
34 | |
|
35 | |
|
36 | |
|
37 | 0 | public static boolean CALLED_TRANS_COMMITTED = false; |
38 | 0 | public static boolean CALLED_TRANS_ROLLEDBACKED = false; |
39 | |
|
40 | |
private PersistedMessageBO message; |
41 | |
|
42 | 0 | public MessageSendingTransactionSynchronization(PersistedMessageBO message) { |
43 | 0 | this.message = message; |
44 | 0 | } |
45 | |
|
46 | |
public void afterCommit() { |
47 | |
|
48 | 0 | } |
49 | |
|
50 | |
public void afterCompletion(int status) { |
51 | 0 | if (status == STATUS_COMMITTED) { |
52 | 0 | KSBServiceLocator.getThreadPool().execute(new MessageServiceInvoker(message)); |
53 | 0 | CALLED_TRANS_COMMITTED = true; |
54 | |
} else { |
55 | 0 | LOG.info("Message " + message + " not sent because transaction not committed."); |
56 | 0 | CALLED_TRANS_ROLLEDBACKED = true; |
57 | |
} |
58 | 0 | } |
59 | |
|
60 | |
public void beforeCommit(boolean readOnly) { |
61 | 0 | } |
62 | |
|
63 | |
public void beforeCompletion() { |
64 | 0 | } |
65 | |
|
66 | |
public void resume() { |
67 | 0 | } |
68 | |
|
69 | |
public void suspend() { |
70 | 0 | } |
71 | |
|
72 | |
public void flush() { |
73 | 0 | } |
74 | |
|
75 | |
} |