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