/** * Unlock */ protected void unlock() { if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("unlock()"); } final ActiveMQRAManagedConnection mcLocal = this.mc; if (mcLocal != null) { mcLocal.unlock(); } // We recreate the lock when returned to the pool // so missing the unlock after disassociation is not important }
/** * Unlock */ protected void unlock() { if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("unlock()"); } final ActiveMQRAManagedConnection mcLocal = this.mc; if (mcLocal != null) { mcLocal.unlock(); } // We recreate the lock when returned to the pool // so missing the unlock after disassociation is not important }
/** * End * * @param xid A global transaction identifier * @param flags One of TMSUCCESS, TMFAIL, or TMSUSPEND. * @throws XAException An error has occurred */ @Override public void end(final Xid xid, final int flags) throws XAException { if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("end(" + xid + ", " + flags + ")"); } managedConnection.lock(); try { xaResource.end(xid, flags); } finally { managedConnection.setInManagedTx(false); managedConnection.unlock(); } }
/** * End * * @param xid A global transaction identifier * @param flags One of TMSUCCESS, TMFAIL, or TMSUSPEND. * @throws XAException An error has occurred */ @Override public void end(final Xid xid, final int flags) throws XAException { if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("end(" + xid + ", " + flags + ")"); } managedConnection.lock(); try { xaResource.end(xid, flags); } finally { managedConnection.setInManagedTx(false); managedConnection.unlock(); } }
/** * Forget * * @param xid A global transaction identifier * @throws XAException An error has occurred */ @Override public void forget(final Xid xid) throws XAException { if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("forget(" + xid + ")"); } managedConnection.lock(); try { xaResource.forget(xid); } finally { managedConnection.setInManagedTx(true); managedConnection.setInManagedTx(false); managedConnection.unlock(); } }
/** * Forget * * @param xid A global transaction identifier * @throws XAException An error has occurred */ @Override public void forget(final Xid xid) throws XAException { if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("forget(" + xid + ")"); } managedConnection.lock(); try { xaResource.forget(xid); } finally { managedConnection.setInManagedTx(true); managedConnection.setInManagedTx(false); managedConnection.unlock(); } }
/** * Commit * * @throws ResourceException Thrown if the operation fails */ @Override public void commit() throws ResourceException { if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("commit()"); } mc.lock(); try { if (mc.getSession().getTransacted()) { mc.getSession().commit(); } } catch (JMSException e) { throw new ResourceException("Could not commit LocalTransaction", e); } finally { //mc.setInManagedTx(false); mc.unlock(); } }
/** * Rollback * * @throws ResourceException Thrown if the operation fails */ @Override public void rollback() throws ResourceException { if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("rollback()"); } mc.lock(); try { if (mc.getSession().getTransacted()) { mc.getSession().rollback(); } } catch (JMSException ex) { throw new ResourceException("Could not rollback LocalTransaction", ex); } finally { //mc.setInManagedTx(false); mc.unlock(); } } }
/** * Commit * * @throws ResourceException Thrown if the operation fails */ @Override public void commit() throws ResourceException { if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("commit()"); } mc.lock(); try { if (mc.getSession().getTransacted()) { mc.getSession().commit(); } } catch (JMSException e) { throw new ResourceException("Could not commit LocalTransaction", e); } finally { //mc.setInManagedTx(false); mc.unlock(); } }
/** * Rollback * * @throws ResourceException Thrown if the operation fails */ @Override public void rollback() throws ResourceException { if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("rollback()"); } mc.lock(); try { if (mc.getSession().getTransacted()) { mc.getSession().rollback(); } } catch (JMSException ex) { throw new ResourceException("Could not rollback LocalTransaction", ex); } finally { //mc.setInManagedTx(false); mc.unlock(); } } }
/** * Start * * @param xid A global transaction identifier * @param flags One of TMNOFLAGS, TMJOIN, or TMRESUME * @throws XAException An error has occurred */ @Override public void start(final Xid xid, final int flags) throws XAException { if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("start(" + xid + ", " + flags + ")"); } managedConnection.lock(); ClientSessionInternal sessionInternal = (ClientSessionInternal) xaResource; try { try { //this resets any tx stuff, we assume here that the tm and jca layer are well behaved when it comes to this sessionInternal.resetIfNeeded(); } catch (ActiveMQException e) { ActiveMQRALogger.LOGGER.problemResettingXASession(e); XAException xaException = new XAException(XAException.XAER_RMFAIL); xaException.initCause(e); throw xaException; } xaResource.start(xid, flags); } finally { managedConnection.setInManagedTx(true); managedConnection.unlock(); } }
/** * Start * * @param xid A global transaction identifier * @param flags One of TMNOFLAGS, TMJOIN, or TMRESUME * @throws XAException An error has occurred */ @Override public void start(final Xid xid, final int flags) throws XAException { if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("start(" + xid + ", " + flags + ")"); } managedConnection.lock(); ClientSessionInternal sessionInternal = (ClientSessionInternal) xaResource; try { try { //this resets any tx stuff, we assume here that the tm and jca layer are well behaved when it comes to this sessionInternal.resetIfNeeded(); } catch (ActiveMQException e) { ActiveMQRALogger.LOGGER.problemResettingXASession(e); XAException xaException = new XAException(XAException.XAER_RMFAIL); xaException.initCause(e); throw xaException; } xaResource.start(xid, flags); } finally { managedConnection.setInManagedTx(true); managedConnection.unlock(); } }