use of org.apache.qpid.server.protocol.v1_0.type.messaging.Accepted in project qpid-broker-j by apache.
the class TransactionalTransferTest method receiveTransactionalAcquisitionReceiverSettleFirst.
@Test
@SpecificationTest(section = "4.4.2", 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 receiveTransactionalAcquisitionReceiverSettleFirst() throws Exception {
Utils.putMessageOnQueue(getBrokerAdmin(), BrokerAdmin.TEST_QUEUE_NAME, getTestName());
try (FrameTransport transport = new FrameTransport(getBrokerAdmin()).connect()) {
final Interaction interaction = transport.newInteraction();
interaction.negotiateOpen().begin().consumeResponse(Begin.class).txnAttachCoordinatorLink(UnsignedInteger.ZERO, this::coordinatorAttachExpected).txnDeclare().attachRole(Role.RECEIVER).attachHandle(UnsignedInteger.ONE).attachSourceAddress(BrokerAdmin.TEST_QUEUE_NAME).attachRcvSettleMode(ReceiverSettleMode.FIRST).attach().consumeResponse(Attach.class).flowIncomingWindow(UnsignedInteger.ONE).flowNextIncomingIdFromPeerLatestSessionBeginAndDeliveryCount().flowOutgoingWindow(UnsignedInteger.ZERO).flowNextOutgoingId(UnsignedInteger.ZERO).flowLinkCredit(UnsignedInteger.ONE).flowHandleFromLinkHandle().flowProperties(Collections.singletonMap(Symbol.valueOf("txn-id"), interaction.getCurrentTransactionId())).flow().receiveDelivery();
List<Transfer> transfers = interaction.getLatestDelivery();
assertThat(transfers.size(), is(equalTo(1)));
Object data = interaction.decodeLatestDelivery().getDecodedLatestDelivery();
assertThat(data, is(equalTo(getTestName())));
interaction.dispositionSettled(true).dispositionRole(Role.RECEIVER).dispositionTransactionalStateFromCurrentTransaction(new Accepted()).dispositionFirstFromLatestDelivery().disposition().txnDischarge(false);
assertThat(interaction.getCoordinatorLatestDeliveryState(), is(instanceOf(Accepted.class)));
Transfer transfer = transfers.get(0);
assumeThat(transfer.getState(), is(instanceOf(TransactionalState.class)));
assumeThat(((TransactionalState) transfer.getState()).getTxnId(), is(equalTo(interaction.getCurrentTransactionId())));
final String content = getTestName() + "_2";
Utils.putMessageOnQueue(getBrokerAdmin(), BrokerAdmin.TEST_QUEUE_NAME, content);
assertThat(Utils.receiveMessage(getBrokerAdmin(), BrokerAdmin.TEST_QUEUE_NAME), is(equalTo(content)));
}
}
use of org.apache.qpid.server.protocol.v1_0.type.messaging.Accepted in project qpid-broker-j by apache.
the class LinkStoreTestCase method setUp.
@Before
public void setUp() throws Exception {
_linkStore = createLinkStore();
_source = new Source();
_target = new Target();
_source.setAddress(ADDRESS);
_source.setCapabilities(new Symbol[] { Symbol.getSymbol(CAPABILITY) });
_source.setDefaultOutcome(new Rejected());
_source.setDistributionMode(StdDistMode.COPY);
_source.setDurable(TerminusDurability.UNSETTLED_STATE);
_source.setDynamic(Boolean.TRUE);
_source.setExpiryPolicy(TerminusExpiryPolicy.CONNECTION_CLOSE);
_source.setFilter(Collections.singletonMap(Symbol.valueOf("foo"), NoLocalFilter.INSTANCE));
_source.setOutcomes(new Accepted().getSymbol());
_source.setDynamicNodeProperties(Collections.singletonMap(Symbol.valueOf("dynamicProperty"), "dynamicPropertyValue"));
_source.setTimeout(new UnsignedInteger(1));
_target.setTimeout(new UnsignedInteger(2));
_target.setDynamicNodeProperties(Collections.singletonMap(Symbol.valueOf("targetDynamicProperty"), "targetDynamicPropertyValue"));
_target.setDynamic(Boolean.TRUE);
_target.setExpiryPolicy(TerminusExpiryPolicy.LINK_DETACH);
_target.setAddress("bar");
_target.setCapabilities(new Symbol[] { Symbol.getSymbol(CAPABILITY) });
_target.setDurable(TerminusDurability.CONFIGURATION);
}
Aggregations