/** * Simply close proxied session if there is no active transaction. Or if transaction exists, delist session's XA resource * and register a {@link SessionClosingSynchronization} to close the proxied session. * * @throws JMSException */ @Override public void close() throws JMSException { if (transactionHelper.isTransactionAvailable()) { transactionHelper.deregisterXAResource(xaSession.getXAResource()); if (jtaLogger.logger.isTraceEnabled()) { jtaLogger.logger.trace("Delisted " + xaSession + " XA resource from the transaction"); } Synchronization synchronization = new SessionClosingSynchronization(xaSession); transactionHelper.registerSynchronization(synchronization); if (jtaLogger.logger.isTraceEnabled()) { jtaLogger.logger.trace("Registered synchronization to close the session: " + synchronization); } } else { xaSession.close(); } }
/** * Simply close the proxied connection if there is no active transaction. Or register a * {@link ConnectionClosingSynchronization} if active transaction exists. * * @throws JMSException if transaction service has failed (in unexpected way) to obtain transaction status, * or if synchronization registration, or connection closing has failed. */ @Override public void close() throws JMSException { if (transactionHelper.isTransactionAvailable()) { Synchronization synchronization = new ConnectionClosingSynchronization(xaConnection); transactionHelper.registerSynchronization(synchronization); if (jtaLogger.logger.isTraceEnabled()) { jtaLogger.logger.trace("Registered synchronization to close the connection: " + synchronization); } } else { xaConnection.close(); } }
/** * Simply create a session with an XA connection if there is no active transaction. Or create a proxied session and register * it with an active transaction. * * @see SessionProxy * @see Connection#createSession(boolean, int) */ @Override public Session createSession(boolean transacted, int acknowledgeMode) throws JMSException { if (transactionHelper.isTransactionAvailable()) { return createAndRegisterSession(); } return xaConnection.createSession(transacted, acknowledgeMode); }
/** * Create a proxied XA session and enlist its XA resource to the transaction. * <p> * If session's XA resource cannot be enlisted to the transaction, session is closed. * * @return XA session wrapped with {@link SessionProxy}. * @throws JMSException if failure occurred creating XA session or registering its XA resource. */ private Session createAndRegisterSession() throws JMSException { XASession xaSession = xaConnection.createXASession(); Session session = new SessionProxy(xaSession, transactionHelper); try { transactionHelper.registerXAResource(xaSession.getXAResource()); } catch (JMSException e) { xaSession.close(); throw e; } if (jtaLogger.logger.isTraceEnabled()) { jtaLogger.logger.trace("Created new proxied session: " + session); } return session; }
/** * Simply close the proxied connection if there is no active transaction. Or register a * {@link ConnectionClosingSynchronization} if active transaction exists. * * @throws JMSException if transaction service has failed (in unexpected way) to obtain transaction status, * or if synchronization registration, or connection closing has failed. */ @Override public void close() throws JMSException { if (transactionHelper.isTransactionAvailable()) { Synchronization synchronization = new ConnectionClosingSynchronization(xaConnection); transactionHelper.registerSynchronization(synchronization); if (jtaLogger.logger.isTraceEnabled()) { jtaLogger.logger.trace("Registered synchronization to close the connection: " + synchronization); } } else { xaConnection.close(); } }
/** * Simply create a session with an XA connection if there is no active transaction. Or create a proxied session and register * it with an active transaction. * * @see SessionProxy * @see Connection#createSession(boolean, int) */ @Override public Session createSession(boolean transacted, int acknowledgeMode) throws JMSException { if (transactionHelper.isTransactionAvailable()) { return createAndRegisterSession(); } return xaConnection.createSession(transacted, acknowledgeMode); }
/** * Create a proxied XA session and enlist its XA resource to the transaction. * <p> * If session's XA resource cannot be enlisted to the transaction, session is closed. * * @return XA session wrapped with {@link SessionProxy}. * @throws JMSException if failure occurred creating XA session or registering its XA resource. */ private Session createAndRegisterSession() throws JMSException { XASession xaSession = xaConnection.createXASession(); Session session = new SessionProxy(xaSession, transactionHelper); try { transactionHelper.registerXAResource(xaSession.getXAResource()); } catch (JMSException e) { xaSession.close(); throw e; } if (jtaLogger.logger.isTraceEnabled()) { jtaLogger.logger.trace("Created new proxied session: " + session); } return session; }
/** * Simply close proxied session if there is no active transaction. Or if transaction exists, delist session's XA resource * and register a {@link SessionClosingSynchronization} to close the proxied session. * * @throws JMSException */ @Override public void close() throws JMSException { if (transactionHelper.isTransactionAvailable()) { transactionHelper.deregisterXAResource(xaSession.getXAResource()); if (jtaLogger.logger.isTraceEnabled()) { jtaLogger.logger.trace("Delisted " + xaSession + " XA resource from the transaction"); } Synchronization synchronization = new SessionClosingSynchronization(xaSession); transactionHelper.registerSynchronization(synchronization); if (jtaLogger.logger.isTraceEnabled()) { jtaLogger.logger.trace("Registered synchronization to close the session: " + synchronization); } } else { xaSession.close(); } }
/** * Simply close the proxied connection if there is no active transaction. Or register a * {@link ConnectionClosingSynchronization} if active transaction exists. * * @throws JMSException if transaction service has failed (in unexpected way) to obtain transaction status, * or if synchronization registration, or connection closing has failed. */ @Override public void close() throws JMSException { if (transactionHelper.isTransactionAvailable()) { Synchronization synchronization = new ConnectionClosingSynchronization(xaConnection); transactionHelper.registerSynchronization(synchronization); if (jtaLogger.logger.isTraceEnabled()) { jtaLogger.logger.trace("Registered synchronization to close the connection: " + synchronization); } } else { xaConnection.close(); } }
/** * Simply create a session with an XA connection if there is no active transaction. Or create a proxied session and register * it with an active transaction. * * @see SessionProxy * @see Connection#createSession(boolean, int) */ @Override public Session createSession(boolean transacted, int acknowledgeMode) throws JMSException { if (transactionHelper.isTransactionAvailable()) { return createAndRegisterSession(); } return xaConnection.createSession(transacted, acknowledgeMode); }
/** * Create a proxied XA session and enlist its XA resource to the transaction. * <p> * If session's XA resource cannot be enlisted to the transaction, session is closed. * * @return XA session wrapped with {@link SessionProxy}. * @throws JMSException if failure occurred creating XA session or registering its XA resource. */ private Session createAndRegisterSession() throws JMSException { XASession xaSession = xaConnection.createXASession(); Session session = new SessionProxy(xaSession, transactionHelper); try { transactionHelper.registerXAResource(xaSession.getXAResource()); } catch (JMSException e) { xaSession.close(); throw e; } if (jtaLogger.logger.isTraceEnabled()) { jtaLogger.logger.trace("Created new proxied session: " + session); } return session; }
/** * Simply close proxied session if there is no active transaction. Or if transaction exists, delist session's XA resource * and register a {@link SessionClosingSynchronization} to close the proxied session. * * @throws JMSException */ @Override public void close() throws JMSException { if (transactionHelper.isTransactionAvailable()) { transactionHelper.deregisterXAResource(xaSession.getXAResource()); if (jtaLogger.logger.isTraceEnabled()) { jtaLogger.logger.trace("Delisted " + xaSession + " XA resource from the transaction"); } Synchronization synchronization = new SessionClosingSynchronization(xaSession); transactionHelper.registerSynchronization(synchronization); if (jtaLogger.logger.isTraceEnabled()) { jtaLogger.logger.trace("Registered synchronization to close the session: " + synchronization); } } else { xaSession.close(); } }