use of org.apache.qpid.server.protocol.v1_0.type.messaging.Accepted in project qpid-broker-j by apache.
the class TransactionalTransferTest method receiveTransactionalRetirementDischargeFail.
@Test
@SpecificationTest(section = "4.4.2", description = "Transactional Retirement[...] The transaction controller might" + "wish to associate the outcome of a delivery with a transaction.")
public void receiveTransactionalRetirementDischargeFail() throws Exception {
getBrokerAdmin().putMessageOnQueue(BrokerAdmin.TEST_QUEUE_NAME, TEST_MESSAGE_CONTENT);
try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
final Interaction interaction = transport.newInteraction();
final InteractionTransactionalState txnState = interaction.createTransactionalState(UnsignedInteger.ZERO);
interaction.negotiateProtocol().consumeResponse().open().consumeResponse(Open.class).begin().consumeResponse(Begin.class).txnAttachCoordinatorLink(txnState).txnDeclare(txnState).attachRole(Role.RECEIVER).attachHandle(UnsignedInteger.ONE).attachSourceAddress(BrokerAdmin.TEST_QUEUE_NAME).attachRcvSettleMode(ReceiverSettleMode.FIRST).attach().consumeResponse(Attach.class).flowIncomingWindow(UnsignedInteger.ONE).flowNextIncomingId(UnsignedInteger.ZERO).flowOutgoingWindow(UnsignedInteger.ZERO).flowNextOutgoingId(UnsignedInteger.ZERO).flowLinkCredit(UnsignedInteger.ONE).flowHandleFromLinkHandle().flow().receiveDelivery().decodeLatestDelivery();
Object data = interaction.getDecodedLatestDelivery();
assertThat(data, is(equalTo(TEST_MESSAGE_CONTENT)));
interaction.dispositionSettled(true).dispositionRole(Role.RECEIVER).dispositionTransactionalState(txnState.getCurrentTransactionId(), new Accepted()).disposition().txnDischarge(txnState, true);
Object receivedMessage = Utils.receiveMessage(_brokerAddress, BrokerAdmin.TEST_QUEUE_NAME);
assertThat(receivedMessage, is(equalTo(TEST_MESSAGE_CONTENT)));
}
}
use of org.apache.qpid.server.protocol.v1_0.type.messaging.Accepted in project qpid-broker-j by apache.
the class TransactionalTransferTest method receiveTransactionalRetirementReceiverSettleFirst.
@Test
@SpecificationTest(section = "4.4.2", description = "Transactional Retirement[...] The transaction controller might" + "wish to associate the outcome of a delivery with a transaction.")
public void receiveTransactionalRetirementReceiverSettleFirst() throws Exception {
getBrokerAdmin().putMessageOnQueue(BrokerAdmin.TEST_QUEUE_NAME, TEST_MESSAGE_CONTENT);
try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
final Interaction interaction = transport.newInteraction();
final InteractionTransactionalState txnState = interaction.createTransactionalState(UnsignedInteger.ZERO);
interaction.negotiateProtocol().consumeResponse().open().consumeResponse(Open.class).begin().consumeResponse(Begin.class).txnAttachCoordinatorLink(txnState).txnDeclare(txnState).attachRole(Role.RECEIVER).attachHandle(UnsignedInteger.ONE).attachSourceAddress(BrokerAdmin.TEST_QUEUE_NAME).attachRcvSettleMode(ReceiverSettleMode.FIRST).attach().consumeResponse(Attach.class).flowIncomingWindow(UnsignedInteger.ONE).flowNextIncomingId(UnsignedInteger.ZERO).flowOutgoingWindow(UnsignedInteger.ZERO).flowNextOutgoingId(UnsignedInteger.ZERO).flowLinkCredit(UnsignedInteger.ONE).flowHandleFromLinkHandle().flow().receiveDelivery().decodeLatestDelivery();
Object data = interaction.getDecodedLatestDelivery();
assertThat(data, is(equalTo(TEST_MESSAGE_CONTENT)));
interaction.dispositionSettled(true).dispositionRole(Role.RECEIVER).dispositionTransactionalState(txnState.getCurrentTransactionId(), new Accepted()).disposition().txnDischarge(txnState, false);
}
}
use of org.apache.qpid.server.protocol.v1_0.type.messaging.Accepted in project qpid-broker-j by apache.
the class TransactionalTransferTest method receiveTransactionalAcquisitionDischargeFail.
@Test
@SpecificationTest(section = "4.4.3", description = "Transactional Acquisition[...]In the case of the flow frame," + " the transactional work is not necessarily directly" + " initiated or entirely determined when the flow frame" + " arrives at the resource, but can in fact occur at some " + " later point and in ways not necessarily" + " anticipated by the controller.")
public void receiveTransactionalAcquisitionDischargeFail() throws Exception {
getBrokerAdmin().putMessageOnQueue(BrokerAdmin.TEST_QUEUE_NAME, TEST_MESSAGE_CONTENT);
try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
final Interaction interaction = transport.newInteraction();
final InteractionTransactionalState txnState = interaction.createTransactionalState(UnsignedInteger.ZERO);
interaction.negotiateProtocol().consumeResponse().open().consumeResponse(Open.class).begin().consumeResponse(Begin.class).txnAttachCoordinatorLink(txnState).txnDeclare(txnState).attachRole(Role.RECEIVER).attachHandle(UnsignedInteger.ONE).attachSourceAddress(BrokerAdmin.TEST_QUEUE_NAME).attachRcvSettleMode(ReceiverSettleMode.FIRST).attach().consumeResponse(Attach.class).flowIncomingWindow(UnsignedInteger.ONE).flowNextIncomingId(UnsignedInteger.ZERO).flowOutgoingWindow(UnsignedInteger.ZERO).flowNextOutgoingId(UnsignedInteger.ZERO).flowLinkCredit(UnsignedInteger.ONE).flowHandleFromLinkHandle().flowProperties(Collections.singletonMap(Symbol.valueOf("txn-id"), txnState.getCurrentTransactionId())).flow().receiveDelivery();
List<Transfer> transfers = interaction.getLatestDelivery();
assertThat(transfers.size(), is(equalTo(1)));
Transfer transfer = transfers.get(0);
assertThat(transfer.getState(), is(instanceOf(TransactionalState.class)));
assertThat(((TransactionalState) transfer.getState()).getTxnId(), is(equalTo(txnState.getCurrentTransactionId())));
Object data = interaction.decodeLatestDelivery().getDecodedLatestDelivery();
assertThat(data, is(equalTo(TEST_MESSAGE_CONTENT)));
interaction.dispositionSettled(true).dispositionRole(Role.RECEIVER).dispositionTransactionalState(txnState.getCurrentTransactionId(), new Accepted()).disposition().txnDischarge(txnState, true);
assumeThat(getBrokerAdmin().isQueueDepthSupported(), is(true));
assertThat(getBrokerAdmin().getQueueDepthMessages(BrokerAdmin.TEST_QUEUE_NAME), is(equalTo(1)));
}
}
use of org.apache.qpid.server.protocol.v1_0.type.messaging.Accepted in project qpid-broker-j by apache.
the class TransactionalTransferTest method receiveTransactionalRetirementDispositionFailsDueToUnknownTransactionId.
@Test
@SpecificationTest(section = "4.4.2", description = "Transactional Retirement[...]" + " To associate an outcome with a transaction the controller" + " sends a disposition performative which sets the state" + " of the delivery to a transactional-state with the desired" + " transaction identifier and the outcome to be applied" + " upon a successful discharge.")
public void receiveTransactionalRetirementDispositionFailsDueToUnknownTransactionId() throws Exception {
getBrokerAdmin().putMessageOnQueue(BrokerAdmin.TEST_QUEUE_NAME, TEST_MESSAGE_CONTENT);
try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
final Interaction interaction = transport.newInteraction();
final InteractionTransactionalState txnState = interaction.createTransactionalState(UnsignedInteger.ZERO);
List<Transfer> transfers = interaction.negotiateProtocol().consumeResponse().open().consumeResponse(Open.class).begin().consumeResponse(Begin.class).txnAttachCoordinatorLink(txnState).txnDeclare(txnState).attachRole(Role.RECEIVER).attachHandle(UnsignedInteger.ONE).attachSourceAddress(BrokerAdmin.TEST_QUEUE_NAME).attachRcvSettleMode(ReceiverSettleMode.FIRST).attach().consumeResponse(Attach.class).flowIncomingWindow(UnsignedInteger.ONE).flowNextIncomingId(UnsignedInteger.ZERO).flowOutgoingWindow(UnsignedInteger.ZERO).flowNextOutgoingId(UnsignedInteger.ZERO).flowLinkCredit(UnsignedInteger.ONE).flowHandleFromLinkHandle().flow().receiveDelivery().getLatestDelivery();
UnsignedInteger deliveryId = transfers.get(0).getDeliveryId();
assertThat(deliveryId, is(notNullValue()));
Object data = interaction.decodeLatestDelivery().getDecodedLatestDelivery();
assertThat(data, is(equalTo(TEST_MESSAGE_CONTENT)));
Response<?> response = interaction.dispositionSettled(true).dispositionRole(Role.RECEIVER).dispositionTransactionalState(integerToBinary(Integer.MAX_VALUE), new Accepted()).dispositionFirst(deliveryId).disposition().consumeResponse().getLatestResponse();
assertUnknownTransactionIdError(response);
}
}
use of org.apache.qpid.server.protocol.v1_0.type.messaging.Accepted in project qpid-broker-j by apache.
the class SendingLinkEndpoint method flowStateChanged.
@Override
public void flowStateChanged() {
if (Boolean.TRUE.equals(getDrain())) {
if (getLinkCredit().compareTo(UnsignedInteger.ZERO) > 0) {
_draining = true;
getSession().notifyWork(getConsumerTarget());
}
} else {
_draining = false;
}
while (!_resumeAcceptedTransfers.isEmpty() && hasCreditToSend()) {
Accepted accepted = new Accepted();
Transfer xfr = new Transfer();
Binary dt = _resumeAcceptedTransfers.remove(0);
xfr.setDeliveryTag(dt);
xfr.setState(accepted);
xfr.setResume(Boolean.TRUE);
transfer(xfr, true);
xfr.dispose();
}
if (_resumeAcceptedTransfers.isEmpty()) {
getConsumerTarget().flowStateChanged();
}
}
Aggregations