public Discharge newInstance(Object described) { List l = (List) described; Discharge o = new Discharge(); if(l.isEmpty()) { throw new DecodeException("The txn-id field cannot be omitted"); } switch(2 - l.size()) { case 0: o.setFail( (Boolean) l.get( 1 ) ); case 1: o.setTxnId( (Binary) l.get( 0 ) ); } return o; }
public int size() { return _discharge.getFail() != null ? 2 : 1; }
return 12 + discharge.getTxnId().getLength();
public int size() { return _discharge.getFail() != null ? 2 : 1; }
public Discharge newInstance(Object described) { List l = (List) described; Discharge o = new Discharge(); if(l.isEmpty()) { throw new DecodeException("The txn-id field cannot be omitted"); } switch(2 - l.size()) { case 0: o.setFail( (Boolean) l.get( 1 ) ); case 1: o.setTxnId( (Binary) l.get( 0 ) ); } return o; }
public int size() { return _discharge.getFail() != null ? 2 : 1; }
public Discharge newInstance(Object described) { List l = (List) described; Discharge o = new Discharge(); if(l.isEmpty()) { throw new DecodeException("The txn-id field cannot be omitted"); } switch(2 - l.size()) { case 0: o.setFail( (Boolean) l.get( 1 ) ); case 1: o.setTxnId( (Binary) l.get( 0 ) ); } return o; }
public int size() { return _discharge.getFail() != null ? 2 : 1; }
public Discharge newInstance(Object described) { List l = (List) described; Discharge o = new Discharge(); if(l.isEmpty()) { throw new DecodeException("The txn-id field cannot be omitted"); } switch(2 - l.size()) { case 0: o.setFail( (Boolean) l.get( 1 ) ); case 1: o.setTxnId( (Binary) l.get( 0 ) ); } return o; }
if (discharge.getFail()) { try { sessionSPI.rollbackCurrentTX(true);
public CompletableFuture<Void> dischargeAsync(Binary txnId, boolean isCommit) { Message message = Message.Factory.create(); Discharge discharge = new Discharge(); discharge.setFail(!isCommit); discharge.setTxnId(txnId); message.setBody(new AmqpValue(discharge)); return this.internalSender.sendAndReturnDeliveryStateAsync( message, TransactionContext.NULL_TXN) .thenCompose( state -> { if (state instanceof Accepted) { return CompletableFuture.completedFuture(null); } else { CompletableFuture<Void> returnTask = new CompletableFuture<>(); returnTask.completeExceptionally(new UnsupportedOperationException("Received unknown state: " + state.toString())); return returnTask; } }); }
public void discharge(AmqpTransactionId txId, AsyncResult request, boolean commit) throws Exception { if (isClosed()) { Exception failureCause = null; if (commit) { failureCause = new TransactionRolledBackException("Transaction inbout: Coordinator remotely closed"); } else { failureCause = new JMSException("Rollback cannot complete: Coordinator remotely closed"); } request.onFailure(failureCause); return; } // Store the context of this action in the transaction ID for later completion. txId.setState(commit ? AmqpTransactionId.COMMIT_MARKER : AmqpTransactionId.ROLLBACK_MARKER); Message message = Message.Factory.create(); Discharge discharge = new Discharge(); discharge.setFail(!commit); discharge.setTxnId(txId.getRemoteTxId()); message.setBody(new AmqpValue(discharge)); Delivery pendingDelivery = getEndpoint().delivery(tagGenerator.getNextTag()); pendingDelivery.setContext(txId); // Store away for completion pendingDeliveries.add(pendingDelivery); pendingRequests.put(txId, request); sendTxCommand(message); }
} else if (action instanceof Discharge) { final Discharge discharge = (Discharge) action; final LocalTransactionId txId = new LocalTransactionId(connectionId, toLong(discharge.getTxnId())); final byte operation; if (discharge.getFail()) { LOG.trace("rollback transaction {}", txId); operation = TransactionInfo.ROLLBACK;
public void discharge(JmsTransactionId txId, DischargeCompletion request) throws Exception { if (isClosed()) { Exception failureCause = null; if (request.isCommit()) { failureCause = new TransactionRolledBackException("Transaction inbout: Coordinator remotely closed"); } else { failureCause = new JMSException("Rollback cannot complete: Coordinator remotely closed"); } request.onFailure(failureCause); return; } if (txId.getProviderHint() == null) { throw new IllegalStateException("Discharge called with no active Transaction."); } // Store the context of this action in the transaction ID for later completion. txId.setProviderContext(request.isCommit() ? COMMIT_MARKER : ROLLBACK_MARKER); Message message = Message.Factory.create(); Discharge discharge = new Discharge(); discharge.setFail(!request.isCommit()); discharge.setTxnId((Binary) txId.getProviderHint()); message.setBody(new AmqpValue(discharge)); ScheduledFuture<?> timeout = scheduleTimeoutIfNeeded("Timed out waiting for discharge of TX.", request); OperationContext context = new OperationContext(txId, request, timeout); Delivery delivery = getEndpoint().delivery(tagGenerator.getNextTag()); delivery.setContext(context); sendTxCommand(message); }