Search in sources :

Example 26 with Data

use of org.apache.qpid.server.protocol.v1_0.type.messaging.Data in project qpid-broker-j by apache.

the class TransferTest method receiveTransferReceiverSettleSecond.

@Test
@SpecificationTest(section = "2.6.12", description = "Transferring A Message.")
public void receiveTransferReceiverSettleSecond() throws Exception {
    getBrokerAdmin().putMessageOnQueue(BrokerAdmin.TEST_QUEUE_NAME, TEST_MESSAGE_DATA);
    try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
        final Interaction interaction = transport.newInteraction().negotiateProtocol().consumeResponse().open().consumeResponse().begin().consumeResponse().attachRole(Role.RECEIVER).attachSourceAddress(BrokerAdmin.TEST_QUEUE_NAME).attachRcvSettleMode(ReceiverSettleMode.SECOND).attach().consumeResponse().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.is(CoreMatchers.equalTo(TEST_MESSAGE_DATA)));
        Disposition disposition = interaction.dispositionSettled(false).dispositionRole(Role.RECEIVER).dispositionState(new Accepted()).disposition().consumeResponse(Disposition.class).getLatestResponse(Disposition.class);
        assertThat(disposition.getSettled(), is(true));
        interaction.consumeResponse(null, Flow.class);
    }
}
Also used : FrameTransport(org.apache.qpid.tests.protocol.v1_0.FrameTransport) Interaction(org.apache.qpid.tests.protocol.v1_0.Interaction) Disposition(org.apache.qpid.server.protocol.v1_0.type.transport.Disposition) Accepted(org.apache.qpid.server.protocol.v1_0.type.messaging.Accepted) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest) Test(org.junit.Test) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest)

Example 27 with Data

use of org.apache.qpid.server.protocol.v1_0.type.messaging.Data in project qpid-broker-j by apache.

the class TransferTest method receiveTransferReceiverSettleSecondWithImplicitDispositionState.

@Ignore
@Test
@SpecificationTest(section = "2.6.12", description = "Transferring A Message.")
public void receiveTransferReceiverSettleSecondWithImplicitDispositionState() throws Exception {
    getBrokerAdmin().putMessageOnQueue(BrokerAdmin.TEST_QUEUE_NAME, TEST_MESSAGE_DATA);
    try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
        final Interaction interaction = transport.newInteraction().negotiateProtocol().consumeResponse().open().consumeResponse().begin().consumeResponse().attachRole(Role.RECEIVER).attachSourceAddress(BrokerAdmin.TEST_QUEUE_NAME).attachRcvSettleMode(ReceiverSettleMode.SECOND).attachSourceOutcomes().attachSourceDefaultOutcome(null).attach().consumeResponse().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.is(CoreMatchers.equalTo(TEST_MESSAGE_DATA)));
        Disposition disposition = interaction.dispositionSettled(false).dispositionRole(Role.RECEIVER).dispositionState(null).disposition().consumeResponse(Disposition.class).getLatestResponse(Disposition.class);
        assertThat(disposition.getSettled(), is(true));
        interaction.consumeResponse(null, Flow.class);
    }
}
Also used : FrameTransport(org.apache.qpid.tests.protocol.v1_0.FrameTransport) Interaction(org.apache.qpid.tests.protocol.v1_0.Interaction) Disposition(org.apache.qpid.server.protocol.v1_0.type.transport.Disposition) Ignore(org.junit.Ignore) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest) Test(org.junit.Test) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest)

Example 28 with Data

use of org.apache.qpid.server.protocol.v1_0.type.messaging.Data in project qpid-broker-j by apache.

the class TransferTest method receiveMixtureOfTransactionalAndNonTransactionalDeliveries.

@Test
@SpecificationTest(section = "2.6.12", description = "Transferring A Message.")
public void receiveMixtureOfTransactionalAndNonTransactionalDeliveries() throws Exception {
    int numberOfMessages = 4;
    for (int i = 0; i < numberOfMessages; i++) {
        getBrokerAdmin().putMessageOnQueue(BrokerAdmin.TEST_QUEUE_NAME, TEST_MESSAGE_DATA + "_" + i);
    }
    try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
        final Interaction interaction = transport.newInteraction().negotiateProtocol().consumeResponse().open().consumeResponse().begin().consumeResponse().attachRole(Role.RECEIVER).attachSourceAddress(BrokerAdmin.TEST_QUEUE_NAME).attachRcvSettleMode(ReceiverSettleMode.FIRST).attachHandle(UnsignedInteger.ZERO).attach().consumeResponse().flowIncomingWindow(UnsignedInteger.valueOf(numberOfMessages)).flowNextIncomingId(UnsignedInteger.ZERO).flowOutgoingWindow(UnsignedInteger.ZERO).flowNextOutgoingId(UnsignedInteger.ZERO).flowLinkCredit(UnsignedInteger.valueOf(numberOfMessages)).flowHandleFromLinkHandle().flow();
        for (int i = 0; i < numberOfMessages; i++) {
            interaction.receiveDelivery(Flow.class).decodeLatestDelivery();
            Object data = interaction.getDecodedLatestDelivery();
            assertThat(data, Is.is(CoreMatchers.equalTo(TEST_MESSAGE_DATA + "_" + i)));
            assertThat(interaction.getLatestDeliveryId(), Is.is(equalTo(UnsignedInteger.valueOf(i))));
        }
        final InteractionTransactionalState txnState = interaction.createTransactionalState(UnsignedInteger.ONE);
        interaction.txnAttachCoordinatorLink(txnState).txnDeclare(txnState);
        interaction.dispositionSettled(true).dispositionRole(Role.RECEIVER).dispositionFirst(UnsignedInteger.ZERO).dispositionLast(UnsignedInteger.ONE).dispositionState(new Accepted()).disposition().dispositionSettled(true).dispositionRole(Role.RECEIVER).dispositionFirst(UnsignedInteger.valueOf(2)).dispositionLast(UnsignedInteger.valueOf(3)).dispositionTransactionalState(txnState.getCurrentTransactionId(), new Accepted()).disposition();
        final Discharge discharge = new Discharge();
        discharge.setTxnId(txnState.getCurrentTransactionId());
        discharge.setFail(false);
        interaction.transferHandle(txnState.getHandle()).transferDeliveryId(UnsignedInteger.valueOf(4)).transferDeliveryTag(new Binary(("transaction-" + 4).getBytes(StandardCharsets.UTF_8))).transferPayloadData(discharge).transfer();
        Disposition declareTransactionDisposition = null;
        Flow coordinatorFlow = null;
        do {
            interaction.consumeResponse(Disposition.class, Flow.class);
            Response<?> response = interaction.getLatestResponse();
            if (response.getBody() instanceof Disposition) {
                declareTransactionDisposition = (Disposition) response.getBody();
            }
            if (response.getBody() instanceof Flow) {
                final Flow flowResponse = (Flow) response.getBody();
                if (flowResponse.getHandle().equals(txnState.getHandle())) {
                    coordinatorFlow = flowResponse;
                }
            }
        } while (declareTransactionDisposition == null || coordinatorFlow == null);
        if (getBrokerAdmin().isQueueDepthSupported()) {
            assertThat(getBrokerAdmin().getQueueDepthMessages(BrokerAdmin.TEST_QUEUE_NAME), is(equalTo(0)));
        }
    }
    String messageText = TEST_MESSAGE_DATA + "_" + 4;
    getBrokerAdmin().putMessageOnQueue(BrokerAdmin.TEST_QUEUE_NAME, messageText);
    Object receivedMessage = Utils.receiveMessage(_brokerAddress, BrokerAdmin.TEST_QUEUE_NAME);
    assertThat(receivedMessage, is(equalTo(messageText)));
}
Also used : FrameTransport(org.apache.qpid.tests.protocol.v1_0.FrameTransport) InteractionTransactionalState(org.apache.qpid.tests.protocol.v1_0.InteractionTransactionalState) Interaction(org.apache.qpid.tests.protocol.v1_0.Interaction) Disposition(org.apache.qpid.server.protocol.v1_0.type.transport.Disposition) Binary(org.apache.qpid.server.protocol.v1_0.type.Binary) Accepted(org.apache.qpid.server.protocol.v1_0.type.messaging.Accepted) Discharge(org.apache.qpid.server.protocol.v1_0.type.transaction.Discharge) Flow(org.apache.qpid.server.protocol.v1_0.type.transport.Flow) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest) Test(org.junit.Test) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest)

Example 29 with Data

use of org.apache.qpid.server.protocol.v1_0.type.messaging.Data 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)));
    }
}
Also used : FrameTransport(org.apache.qpid.tests.protocol.v1_0.FrameTransport) InteractionTransactionalState(org.apache.qpid.tests.protocol.v1_0.InteractionTransactionalState) Interaction(org.apache.qpid.tests.protocol.v1_0.Interaction) Attach(org.apache.qpid.server.protocol.v1_0.type.transport.Attach) Begin(org.apache.qpid.server.protocol.v1_0.type.transport.Begin) Accepted(org.apache.qpid.server.protocol.v1_0.type.messaging.Accepted) Open(org.apache.qpid.server.protocol.v1_0.type.transport.Open) Test(org.junit.Test) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest)

Example 30 with Data

use of org.apache.qpid.server.protocol.v1_0.type.messaging.Data 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);
    }
}
Also used : FrameTransport(org.apache.qpid.tests.protocol.v1_0.FrameTransport) InteractionTransactionalState(org.apache.qpid.tests.protocol.v1_0.InteractionTransactionalState) Interaction(org.apache.qpid.tests.protocol.v1_0.Interaction) Attach(org.apache.qpid.server.protocol.v1_0.type.transport.Attach) Begin(org.apache.qpid.server.protocol.v1_0.type.transport.Begin) Accepted(org.apache.qpid.server.protocol.v1_0.type.messaging.Accepted) Open(org.apache.qpid.server.protocol.v1_0.type.transport.Open) Test(org.junit.Test) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest)

Aggregations

Binary (org.apache.qpid.server.protocol.v1_0.type.Binary)42 QpidByteBuffer (org.apache.qpid.server.bytebuffer.QpidByteBuffer)39 Data (org.apache.qpid.server.protocol.v1_0.type.messaging.Data)32 NamedAddressSpace (org.apache.qpid.server.model.NamedAddressSpace)30 Message_1_0 (org.apache.qpid.server.protocol.v1_0.Message_1_0)29 ApplicationProperties (org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties)29 Properties (org.apache.qpid.server.protocol.v1_0.type.messaging.Properties)28 FrameTransport (org.apache.qpid.tests.protocol.v1_0.FrameTransport)19 Interaction (org.apache.qpid.tests.protocol.v1_0.Interaction)19 Test (org.junit.Test)19 SpecificationTest (org.apache.qpid.tests.protocol.SpecificationTest)18 MessageTransferMessage (org.apache.qpid.server.protocol.v0_10.MessageTransferMessage)14 AMQMessage (org.apache.qpid.server.protocol.v0_8.AMQMessage)14 Accepted (org.apache.qpid.server.protocol.v1_0.type.messaging.Accepted)13 Attach (org.apache.qpid.server.protocol.v1_0.type.transport.Attach)12 ArrayList (java.util.ArrayList)9 Begin (org.apache.qpid.server.protocol.v1_0.type.transport.Begin)9 Open (org.apache.qpid.server.protocol.v1_0.type.transport.Open)9 Transfer (org.apache.qpid.server.protocol.v1_0.type.transport.Transfer)8 InteractionTransactionalState (org.apache.qpid.tests.protocol.v1_0.InteractionTransactionalState)8