in qpid-jms-client/src/main/java/org/apache/qpid/jms/JmsLocalTransactionContext.java [177:252]
public void commit() throws JMSException {
lock.writeLock().lock();
try {
if (isInDoubt()) {
try {
rollback();
} catch (Exception e) {
LOG.trace("Error during rollback of failed TX: {}", e);
}
throw new TransactionRolledBackException("Transaction failed and has been rolled back.");
} else {
LOG.debug("Commit: {}", transactionInfo.getId());
final JmsTransactionId oldTransactionId = transactionInfo.getId();
final JmsTransactionInfo nextTx = getNextTransactionInfo();
try {
connection.commit(transactionInfo, nextTx, new ProviderSynchronization() {
@Override
public void onPendingSuccess() {
reset();
JmsLocalTransactionContext.this.transactionInfo = nextTx;
}
@Override
public void onPendingFailure(ProviderException cause) {
reset();
JmsLocalTransactionContext.this.transactionInfo = nextTx;
}
});
if (listener != null) {
try {
listener.onTransactionCommitted();
} catch (Throwable error) {
LOG.trace("Local TX listener error ignored: {}", error);
}
try {
listener.onTransactionStarted();
} catch (Throwable error) {
LOG.trace("Local TX listener error ignored: {}", error);
}
}
} catch (JMSException cause) {
LOG.info("Commit failed for transaction: {}", oldTransactionId);
if (listener != null) {
try {
listener.onTransactionRolledBack();
} catch (Throwable error) {
LOG.trace("Local TX listener error ignored: {}", error);
}
}
throw cause;
} finally {
try {
// If the provider failed to start a new transaction there will not be
// a current provider transaction id present, so we attempt to create
// one to recover our state.
if (nextTx.getId().getProviderTxId() == null) {
begin();
}
} catch (Exception e) {
// TODO
// At this point the transacted session is now unrecoverable, we should
// probably close it.
LOG.info("Failed to start new Transaction after failed rollback of: {}", oldTransactionId);
}
}
}
} finally {
lock.writeLock().unlock();
}
}