public void begin(final JmsTransactionId txId, final AsyncResult request) throws Exception { if (current != null) { throw new IOException("Begin called while a TX is still Active."); } final AsyncResult declareCompletion = new AsyncResult() { @Override public void onSuccess() { current = txId; request.onSuccess(); } @Override public void onFailure(Throwable result) { current = null; request.onFailure(result); } @Override public boolean isComplete() { return current != null; } }; if (coordinator == null || coordinator.isClosed()) { AmqpTransactionCoordinatorBuilder builder = new AmqpTransactionCoordinatorBuilder(this, session.getResourceInfo()); builder.buildResource( new AsyncResult() { @Override public void onSuccess() { try { coordinator.declare(txId, declareCompletion); } catch (Exception e) { request.onFailure(e); } } @Override public void onFailure(Throwable result) { request.onFailure(result); } @Override public boolean isComplete() { return request.isComplete(); } }); } else { coordinator.declare(txId, declareCompletion); } }
@Override public AmqpProvider getProvider() { return session.getProvider(); }