/** * Resume all enlisted resources in the current transaction context. * @throws XAException if the resource threw an exception during resume. */ public void resume() throws XAException { // all XAResource needs to be re-enlisted but this must happen // outside the Scheduler's iteration as enlist() can change the // collection's content and confuse the iterator. List<XAResourceHolderState> toBeReEnlisted = new ArrayList<XAResourceHolderState>(); for (XAResourceHolderState xaResourceHolderState : resources) { if (log.isDebugEnabled()) { log.debug("resuming " + xaResourceHolderState); } // If a prepared statement is (re-)used after suspend/resume is performed its XAResource needs to be // re-enlisted. This must be done outside this loop or that will confuse the iterator! toBeReEnlisted.add(new XAResourceHolderState(xaResourceHolderState)); } if (toBeReEnlisted.size() > 0 && log.isDebugEnabled()) log.debug("re-enlisting " + toBeReEnlisted.size() + " resource(s)"); for (XAResourceHolderState xaResourceHolderState : toBeReEnlisted) { if (log.isDebugEnabled()) { log.debug("re-enlisting resource " + xaResourceHolderState); } try { enlist(xaResourceHolderState); xaResourceHolderState.getXAResourceHolder().putXAResourceHolderState(xaResourceHolderState.getXid(), xaResourceHolderState); } catch (BitronixSystemException ex) { throw new BitronixXAException("error re-enlisting resource during resume: " + xaResourceHolderState, XAException.XAER_RMERR, ex); } } }
/** * Resume all enlisted resources in the current transaction context. * @throws XAException if the resource threw an exception during resume. */ public void resume() throws XAException { // all XAResource needs to be re-enlisted but this must happen // outside the Scheduler's iteration as enlist() can change the // collection's content and confuse the iterator. List<XAResourceHolderState> toBeReEnlisted = new ArrayList<XAResourceHolderState>(); for (XAResourceHolderState xaResourceHolderState : resources) { if (log.isDebugEnabled()) log.debug("resuming " + xaResourceHolderState); // If a prepared statement is (re-)used after suspend/resume is performed its XAResource needs to be // re-enlisted. This must be done outside this loop or that will confuse the iterator! toBeReEnlisted.add(new XAResourceHolderState(xaResourceHolderState)); } if (toBeReEnlisted.size() > 0 && log.isDebugEnabled()) log.debug("re-enlisting " + toBeReEnlisted.size() + " resource(s)"); for (XAResourceHolderState xaResourceHolderState : toBeReEnlisted) { if (log.isDebugEnabled()) log.debug("re-enlisting resource " + xaResourceHolderState); try { enlist(xaResourceHolderState); xaResourceHolderState.getXAResourceHolder().putXAResourceHolderState(xaResourceHolderState.getXid(), xaResourceHolderState); } catch (BitronixSystemException ex) { throw new BitronixXAException("error re-enlisting resource during resume: " + xaResourceHolderState, XAException.XAER_RMERR, ex); } } }
/** * Resume all enlisted resources in the current transaction context. * @throws XAException if the resource threw an exception during resume. */ public void resume() throws XAException { // all XAResource needs to be re-enlisted but this must happen // outside the Scheduler's iteration as enlist() can change the // collection's content and confuse the iterator. List<XAResourceHolderState> toBeReEnlisted = new ArrayList<XAResourceHolderState>(); for (XAResourceHolderState xaResourceHolderState : resources) { if (log.isDebugEnabled()) { log.debug("resuming " + xaResourceHolderState); } // If a prepared statement is (re-)used after suspend/resume is performed its XAResource needs to be // re-enlisted. This must be done outside this loop or that will confuse the iterator! toBeReEnlisted.add(new XAResourceHolderState(xaResourceHolderState)); } if (toBeReEnlisted.size() > 0 && log.isDebugEnabled()) log.debug("re-enlisting " + toBeReEnlisted.size() + " resource(s)"); for (XAResourceHolderState xaResourceHolderState : toBeReEnlisted) { if (log.isDebugEnabled()) { log.debug("re-enlisting resource " + xaResourceHolderState); } try { enlist(xaResourceHolderState); xaResourceHolderState.getXAResourceHolder().putXAResourceHolderState(xaResourceHolderState.getXid(), xaResourceHolderState); } catch (BitronixSystemException ex) { throw new BitronixXAException("error re-enlisting resource during resume: " + xaResourceHolderState, XAException.XAER_RMERR, ex); } } }
/** * Resume all enlisted resources in the current transaction context. * @throws XAException if the resource threw an exception during resume. */ public void resume() throws XAException { // all XAResource needs to be re-enlisted but this must happen // outside the Scheduler's iteration as enlist() can change the // collection's content and confuse the iterator. List<XAResourceHolderState> toBeReEnlisted = new ArrayList<XAResourceHolderState>(); for (XAResourceHolderState xaResourceHolderState : resources) { if (log.isDebugEnabled()) log.debug("resuming " + xaResourceHolderState); // If a prepared statement is (re-)used after suspend/resume is performed its XAResource needs to be // re-enlisted. This must be done outside this loop or that will confuse the iterator! toBeReEnlisted.add(new XAResourceHolderState(xaResourceHolderState)); } if (toBeReEnlisted.size() > 0 && log.isDebugEnabled()) log.debug("re-enlisting " + toBeReEnlisted.size() + " resource(s)"); for (XAResourceHolderState xaResourceHolderState : toBeReEnlisted) { if (log.isDebugEnabled()) log.debug("re-enlisting resource " + xaResourceHolderState); try { enlist(xaResourceHolderState); xaResourceHolderState.getXAResourceHolder().putXAResourceHolderState(xaResourceHolderState.getXid(), xaResourceHolderState); } catch (BitronixSystemException ex) { throw new BitronixXAException("error re-enlisting resource during resume: " + xaResourceHolderState, XAException.XAER_RMERR, ex); } } }
public boolean enlistResource(XAResource xaResource) throws RollbackException, IllegalStateException, SystemException { if (status == Status.STATUS_NO_TRANSACTION) throw new IllegalStateException("transaction hasn't started yet"); if (status == Status.STATUS_MARKED_ROLLBACK) throw new BitronixRollbackException("transaction has been marked as rollback only"); if (isDone()) throw new IllegalStateException("transaction started or finished 2PC, cannot enlist any more resource"); XAResourceHolder resourceHolder = ResourceRegistrar.findXAResourceHolder(xaResource); if (resourceHolder == null) throw new BitronixSystemException("unknown XAResource " + xaResource + ", it does not belong to a registered resource"); XAResourceHolderState resourceHolderState = new XAResourceHolderState(resourceHolder, resourceHolder.getResourceBean()); // resource timeout must be set here so manually enlisted resources can receive it resourceHolderState.setTransactionTimeoutDate(timeoutDate); try { resourceManager.enlist(resourceHolderState); } catch (XAException ex) { String extraErrorDetails = TransactionManagerServices.getExceptionAnalyzer().extractExtraXAExceptionDetails(ex); if (BitronixXAException.isUnilateralRollback(ex)) { // if the resource unilaterally rolled back, the transaction will never be able to commit -> mark it as rollback only setStatus(Status.STATUS_MARKED_ROLLBACK); throw new BitronixRollbackException("resource " + resourceHolderState + " unilaterally rolled back, error=" + Decoder.decodeXAExceptionErrorCode(ex) + (extraErrorDetails == null ? "" : ", extra error=" + extraErrorDetails), ex); } throw new BitronixSystemException("cannot enlist " + resourceHolderState + ", error=" + Decoder.decodeXAExceptionErrorCode(ex) + (extraErrorDetails == null ? "" : ", extra error=" + extraErrorDetails), ex); } resourceHolder.putXAResourceHolderState(resourceHolderState.getXid(), resourceHolderState); return true; }
@Override public boolean enlistResource(XAResource xaResource) throws RollbackException, IllegalStateException, SystemException { if (status == Status.STATUS_NO_TRANSACTION) throw new IllegalStateException("transaction hasn't started yet"); if (status == Status.STATUS_MARKED_ROLLBACK) throw new BitronixRollbackException("transaction has been marked as rollback only"); if (isDone()) throw new IllegalStateException("transaction started or finished 2PC, cannot enlist any more resource"); XAResourceHolder resourceHolder = ResourceRegistrar.findXAResourceHolder(xaResource); if (resourceHolder == null) throw new BitronixSystemException("unknown XAResource " + xaResource + ", it does not belong to a registered resource"); XAResourceHolderState resourceHolderState = new XAResourceHolderState(resourceHolder, resourceHolder.getResourceBean()); // resource timeout must be set here so manually enlisted resources can receive it resourceHolderState.setTransactionTimeoutDate(timeoutDate); try { resourceManager.enlist(resourceHolderState); } catch (XAException ex) { String extraErrorDetails = TransactionManagerServices.getExceptionAnalyzer().extractExtraXAExceptionDetails(ex); if (BitronixXAException.isUnilateralRollback(ex)) { // if the resource unilaterally rolled back, the transaction will never be able to commit -> mark it as rollback only setStatus(Status.STATUS_MARKED_ROLLBACK); throw new BitronixRollbackException("resource " + resourceHolderState + " unilaterally rolled back, error=" + Decoder.decodeXAExceptionErrorCode(ex) + (extraErrorDetails == null ? "" : ", extra error=" + extraErrorDetails), ex); } throw new BitronixSystemException("cannot enlist " + resourceHolderState + ", error=" + Decoder.decodeXAExceptionErrorCode(ex) + (extraErrorDetails == null ? "" : ", extra error=" + extraErrorDetails), ex); } resourceHolder.putXAResourceHolderState(resourceHolderState.getXid(), resourceHolderState); return true; }
public boolean enlistResource(XAResource xaResource) throws RollbackException, IllegalStateException, SystemException { if (status == Status.STATUS_NO_TRANSACTION) throw new IllegalStateException("transaction hasn't started yet"); if (status == Status.STATUS_MARKED_ROLLBACK) throw new BitronixRollbackException("transaction has been marked as rollback only"); if (isDone()) throw new IllegalStateException("transaction started or finished 2PC, cannot enlist any more resource"); XAResourceHolder resourceHolder = ResourceRegistrar.findXAResourceHolder(xaResource); if (resourceHolder == null) throw new BitronixSystemException("unknown XAResource " + xaResource + ", it does not belong to a registered resource"); XAResourceHolderState resourceHolderState = new XAResourceHolderState(resourceHolder, resourceHolder.getResourceBean()); // resource timeout must be set here so manually enlisted resources can receive it resourceHolderState.setTransactionTimeoutDate(timeoutDate); try { resourceManager.enlist(resourceHolderState); } catch (XAException ex) { String extraErrorDetails = TransactionManagerServices.getExceptionAnalyzer().extractExtraXAExceptionDetails(ex); if (BitronixXAException.isUnilateralRollback(ex)) { // if the resource unilaterally rolled back, the transaction will never be able to commit -> mark it as rollback only setStatus(Status.STATUS_MARKED_ROLLBACK); throw new BitronixRollbackException("resource " + resourceHolderState + " unilaterally rolled back, error=" + Decoder.decodeXAExceptionErrorCode(ex) + (extraErrorDetails == null ? "" : ", extra error=" + extraErrorDetails), ex); } throw new BitronixSystemException("cannot enlist " + resourceHolderState + ", error=" + Decoder.decodeXAExceptionErrorCode(ex) + (extraErrorDetails == null ? "" : ", extra error=" + extraErrorDetails), ex); } resourceHolder.putXAResourceHolderState(resourceHolderState.getXid(), resourceHolderState); return true; }
@Override public boolean enlistResource(XAResource xaResource) throws RollbackException, IllegalStateException, SystemException { if (status == Status.STATUS_NO_TRANSACTION) throw new IllegalStateException("transaction hasn't started yet"); if (status == Status.STATUS_MARKED_ROLLBACK) throw new BitronixRollbackException("transaction has been marked as rollback only"); if (isDone()) throw new IllegalStateException("transaction started or finished 2PC, cannot enlist any more resource"); XAResourceHolder resourceHolder = ResourceRegistrar.findXAResourceHolder(xaResource); if (resourceHolder == null) throw new BitronixSystemException("unknown XAResource " + xaResource + ", it does not belong to a registered resource"); XAResourceHolderState resourceHolderState = new XAResourceHolderState(resourceHolder, resourceHolder.getResourceBean()); // resource timeout must be set here so manually enlisted resources can receive it resourceHolderState.setTransactionTimeoutDate(timeoutDate); try { resourceManager.enlist(resourceHolderState); } catch (XAException ex) { String extraErrorDetails = TransactionManagerServices.getExceptionAnalyzer().extractExtraXAExceptionDetails(ex); if (BitronixXAException.isUnilateralRollback(ex)) { // if the resource unilaterally rolled back, the transaction will never be able to commit -> mark it as rollback only setStatus(Status.STATUS_MARKED_ROLLBACK); throw new BitronixRollbackException("resource " + resourceHolderState + " unilaterally rolled back, error=" + Decoder.decodeXAExceptionErrorCode(ex) + (extraErrorDetails == null ? "" : ", extra error=" + extraErrorDetails), ex); } throw new BitronixSystemException("cannot enlist " + resourceHolderState + ", error=" + Decoder.decodeXAExceptionErrorCode(ex) + (extraErrorDetails == null ? "" : ", extra error=" + extraErrorDetails), ex); } resourceHolder.putXAResourceHolderState(resourceHolderState.getXid(), resourceHolderState); return true; }