List of usage examples for javax.transaction SystemException SystemException
public SystemException()
From source file:org.bytesoft.bytetcc.CompensableTransactionImpl.java
private synchronized void fireRemoteParticipantRecoveryCancel() throws SystemException { boolean errorExists = false; for (int i = 0; i < this.resourceList.size(); i++) { XAResourceArchive current = this.resourceList.get(i); if (current.isRolledback()) { continue; }//from www .j av a 2 s .c om CompensableLogger transactionLogger = this.beanFactory.getCompensableLogger(); XidFactory xidFactory = this.beanFactory.getCompensableXidFactory(); TransactionXid branchXid = (TransactionXid) current.getXid(); TransactionXid globalXid = xidFactory.createGlobalXid(branchXid.getGlobalTransactionId()); try { current.recoveryRollback(globalXid); current.setRolledback(true); current.setCompleted(true); transactionLogger.updateCoordinator(current); logger.info("{}| recovery-cancel remote branch: {}", ByteUtils.byteArrayToString(branchXid.getGlobalTransactionId()), current.getDescriptor().getIdentifier()); } catch (XAException ex) { switch (ex.errorCode) { case XAException.XAER_NOTA: logger.warn( "{}| error occurred while recovery-cancelling remote branch: {}, transaction is not exists!", ByteUtils.byteArrayToString(branchXid.getGlobalTransactionId()), current.getDescriptor().getIdentifier()); break; default: errorExists = true; logger.error("{}| error occurred while recovery-cancelling remote branch: {}", ByteUtils.byteArrayToString(branchXid.getGlobalTransactionId()), current, ex); } } catch (RuntimeException rex) { errorExists = true; logger.error("{}| error occurred while recovery-cancelling remote branch: {}", ByteUtils.byteArrayToString(branchXid.getGlobalTransactionId()), current, rex); } } if (errorExists) { throw new SystemException(); } }
From source file:org.bytesoft.bytetcc.CompensableTransactionImpl.java
public synchronized void forget() throws SystemException { LocalResourceCleaner resourceCleaner = this.beanFactory.getLocalResourceCleaner(); boolean success = true; Map<Xid, String> xidMap = new HashMap<Xid, String>(); for (int i = 0; i < this.archiveList.size(); i++) { CompensableArchive current = this.archiveList.get(i); Xid transactionXid = current.getTransactionXid(); Xid compensableXid = current.getCompensableXid(); if (transactionXid != null) { xidMap.put(transactionXid, current.getTransactionResourceKey()); }/*from www. j a va 2s . c om*/ if (compensableXid != null) { xidMap.put(compensableXid, current.getCompensableResourceKey()); } } for (Iterator<Map.Entry<Xid, String>> itr = xidMap.entrySet().iterator(); itr.hasNext();) { Map.Entry<Xid, String> entry = itr.next(); Xid xid = entry.getKey(); String resource = entry.getValue(); try { resourceCleaner.forget(xid, resource); } catch (RuntimeException rex) { success = false; logger.error("forget-transaction: error occurred while forgetting xid: {}", xid, rex); } } for (int i = 0; i < this.resourceList.size(); i++) { XAResourceArchive current = this.resourceList.get(i); XidFactory xidFactory = this.beanFactory.getCompensableXidFactory(); TransactionXid branchXid = (TransactionXid) current.getXid(); TransactionXid globalXid = xidFactory.createGlobalXid(branchXid.getGlobalTransactionId()); try { current.forget(globalXid); } catch (XAException ex) { switch (ex.errorCode) { case XAException.XAER_NOTA: break; default: success = false; logger.error("forget-transaction: error occurred while forgetting branch: {}", branchXid, ex); } } catch (RuntimeException rex) { success = false; logger.error("forget-transaction: error occurred while forgetting branch: {}", branchXid, rex); } } if (success) { CompensableLogger compensableLogger = this.beanFactory.getCompensableLogger(); TransactionRepository compensableRepository = this.beanFactory.getCompensableRepository(); compensableLogger.deleteTransaction(this.getTransactionArchive()); compensableRepository.removeErrorTransaction(this.transactionContext.getXid()); compensableRepository.removeTransaction(this.transactionContext.getXid()); logger.info("{}| forget transaction.", ByteUtils.byteArrayToString(this.transactionContext.getXid().getGlobalTransactionId())); } else { throw new SystemException(); } }
From source file:org.bytesoft.bytetcc.CompensableTransactionImpl.java
public synchronized void recoveryForget() throws SystemException { LocalResourceCleaner resourceCleaner = this.beanFactory.getLocalResourceCleaner(); boolean success = true; for (int i = 0; i < this.archiveList.size(); i++) { CompensableArchive current = this.archiveList.get(i); String transactionResourceKey = current.getTransactionResourceKey(); String compensableResourceKey = current.getCompensableResourceKey(); if (StringUtils.isNotBlank(transactionResourceKey)) { Xid branchXid = current.getTransactionXid(); try { resourceCleaner.forget(branchXid, transactionResourceKey); } catch (RuntimeException rex) { success = false;/*www .j a va 2 s. com*/ logger.error("forget-transaction: error occurred while forgetting branch: {}", branchXid, rex); } } if (StringUtils.isNotBlank(compensableResourceKey)) { Xid branchXid = current.getCompensableXid(); try { resourceCleaner.forget(branchXid, compensableResourceKey); } catch (RuntimeException rex) { success = false; logger.error("forget-transaction: error occurred while forgetting branch: {}", branchXid, rex); } } } for (int i = 0; i < this.resourceList.size(); i++) { XAResourceArchive current = this.resourceList.get(i); XidFactory xidFactory = this.beanFactory.getCompensableXidFactory(); TransactionXid branchXid = (TransactionXid) current.getXid(); TransactionXid globalXid = xidFactory.createGlobalXid(branchXid.getGlobalTransactionId()); try { current.recoveryForget(globalXid); } catch (XAException ex) { switch (ex.errorCode) { case XAException.XAER_NOTA: break; default: success = false; logger.error("forget-transaction: error occurred while forgetting branch: {}", branchXid, ex); } } catch (RuntimeException rex) { success = false; logger.error("forget-transaction: error occurred while forgetting branch: {}", branchXid, rex); } } if (success) { CompensableLogger compensableLogger = this.beanFactory.getCompensableLogger(); TransactionRepository compensableRepository = this.beanFactory.getCompensableRepository(); compensableLogger.deleteTransaction(this.getTransactionArchive()); compensableRepository.removeErrorTransaction(this.transactionContext.getXid()); compensableRepository.removeTransaction(this.transactionContext.getXid()); logger.info("{}| forget transaction.", ByteUtils.byteArrayToString(this.transactionContext.getXid().getGlobalTransactionId())); } else { throw new SystemException(); } }