Exemplo n.º 1
0
  QueueSession getQueueSession() throws InitialisationException {
    QueueManager qm = MuleManager.getInstance().getQueueManager();
    UMOTransaction tx = TransactionCoordination.getInstance().getTransaction();
    if (tx != null) {
      if (tx.hasResource(qm)) {
        if (logger.isDebugEnabled()) {
          logger.debug("Retrieving queue session from current transaction");
        }
        return (QueueSession) tx.getResource(qm);
      }
    }

    if (logger.isDebugEnabled()) {
      logger.debug("Retrieving new queue session from queue manager");
    }

    QueueSession session = qm.getQueueSession();
    if (tx != null) {
      logger.debug("Binding queue session to current transaction");
      try {
        tx.bindResource(qm, session);
      } catch (TransactionException e) {
        throw new RuntimeException("Could not bind queue session to current transaction", e);
      }
    }
    return session;
  }
 public VMTransaction(MuleContext muleContext, boolean initialize) throws TransactionException {
   super(muleContext);
   if (initialize) {
     QueueManager qm = muleContext.getQueueManager();
     QueueSession qs = qm.getQueueSession();
     bindResource(qm, qs);
   }
 }