Search in sources :

Example 1 with BasicAckBody

use of org.apache.qpid.server.protocol.v0_8.transport.BasicAckBody in project qpid-broker-j by apache.

the class PublisherConfirmsTest method publishWithTransactionalConfirms.

/**
 * Qpid allows publisher confirms to be used with transactions.  This is beyond what RabbitMQ supports.
 */
@Test
public void publishWithTransactionalConfirms() throws Exception {
    try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
        final Interaction interaction = transport.newInteraction();
        final BasicAckBody ackBody = interaction.openAnonymousConnection().channel().open().consumeResponse(ChannelOpenOkBody.class).tx().select().consumeResponse(TxSelectOkBody.class).basic().confirmSelect().consumeResponse(ConfirmSelectOkBody.class).basic().publishExchange("").publishRoutingKey(BrokerAdmin.TEST_QUEUE_NAME).content("Test").publishMessage().consumeResponse().getLatestResponse(BasicAckBody.class);
        assertThat(ackBody.getDeliveryTag(), is(equalTo(1L)));
        assertThat(getBrokerAdmin().getQueueDepthMessages(BrokerAdmin.TEST_QUEUE_NAME), is(equalTo(0)));
        interaction.tx().commit().consumeResponse(TxCommitOkBody.class);
        assertThat(getBrokerAdmin().getQueueDepthMessages(BrokerAdmin.TEST_QUEUE_NAME), is(equalTo(1)));
    }
}
Also used : FrameTransport(org.apache.qpid.tests.protocol.v0_8.FrameTransport) ConfirmSelectOkBody(org.apache.qpid.server.protocol.v0_8.transport.ConfirmSelectOkBody) Interaction(org.apache.qpid.tests.protocol.v0_8.Interaction) BasicAckBody(org.apache.qpid.server.protocol.v0_8.transport.BasicAckBody) ChannelOpenOkBody(org.apache.qpid.server.protocol.v0_8.transport.ChannelOpenOkBody) Test(org.junit.Test) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest)

Example 2 with BasicAckBody

use of org.apache.qpid.server.protocol.v0_8.transport.BasicAckBody in project qpid-broker-j by apache.

the class PublisherConfirmsTest method publishUnroutableMessageWithTransactionalConfirms.

@Test
public void publishUnroutableMessageWithTransactionalConfirms() throws Exception {
    try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
        final Interaction interaction = transport.newInteraction();
        interaction.openAnonymousConnection().channel().open().consumeResponse(ChannelOpenOkBody.class).tx().select().consumeResponse(TxSelectOkBody.class).basic().confirmSelect().consumeResponse(ConfirmSelectOkBody.class).basic().publishExchange("").publishRoutingKey("unrouteable").publishMandatory(true).publishMessage().basic().publishExchange("").publishRoutingKey(BrokerAdmin.TEST_QUEUE_NAME).publishMandatory(true).publishMessage();
        final BasicNackBody nackBody = interaction.consumeResponse().getLatestResponse(BasicNackBody.class);
        assertThat(nackBody.getDeliveryTag(), is(equalTo(1L)));
        final BasicAckBody ackBody = interaction.consumeResponse().getLatestResponse(BasicAckBody.class);
        assertThat(ackBody.getDeliveryTag(), is(equalTo(2L)));
        assertThat(getBrokerAdmin().getQueueDepthMessages(BrokerAdmin.TEST_QUEUE_NAME), is(equalTo(0)));
        interaction.tx().commit();
        final Set<Class<?>> outstanding = Sets.newHashSet(TxCommitOkBody.class, BasicReturnBody.class, ContentHeaderBody.class);
        while (!outstanding.isEmpty()) {
            final Response<?> response = interaction.consumeResponse(outstanding.toArray(new Class<?>[outstanding.size()])).getLatestResponse();
            final boolean remove = outstanding.remove(response.getBody().getClass());
            assertThat("" + response, remove, is(equalTo(true)));
        }
        assertThat(getBrokerAdmin().getQueueDepthMessages(BrokerAdmin.TEST_QUEUE_NAME), is(equalTo(1)));
    }
}
Also used : FrameTransport(org.apache.qpid.tests.protocol.v0_8.FrameTransport) Interaction(org.apache.qpid.tests.protocol.v0_8.Interaction) TxSelectOkBody(org.apache.qpid.server.protocol.v0_8.transport.TxSelectOkBody) BasicAckBody(org.apache.qpid.server.protocol.v0_8.transport.BasicAckBody) BasicNackBody(org.apache.qpid.server.protocol.v0_8.transport.BasicNackBody) Test(org.junit.Test) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest)

Example 3 with BasicAckBody

use of org.apache.qpid.server.protocol.v0_8.transport.BasicAckBody in project qpid-broker-j by apache.

the class PublisherConfirmsTest method publishMessage.

@Test
@SpecificationTest(section = "https://www.rabbitmq.com/confirms.html", description = "Once a channel is in confirm mode, both the broker and the client count messages " + "(counting starts at 1 on the first confirm.select)The broker then confirms messages as " + "it handles them by sending a basic.ack on the same channel. The delivery-tag field " + "contains the sequence number of the confirmed message.")
public void publishMessage() throws Exception {
    try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
        final Interaction interaction = transport.newInteraction();
        BasicAckBody ackBody = interaction.openAnonymousConnection().channel().open().consumeResponse(ChannelOpenOkBody.class).basic().confirmSelect().consumeResponse(ConfirmSelectOkBody.class).basic().publishExchange("").publishRoutingKey(BrokerAdmin.TEST_QUEUE_NAME).content("Test").publishMessage().consumeResponse().getLatestResponse(BasicAckBody.class);
        assertThat(ackBody.getDeliveryTag(), is(equalTo(1L)));
        assertThat(getBrokerAdmin().getQueueDepthMessages(BrokerAdmin.TEST_QUEUE_NAME), is(equalTo(1)));
    }
}
Also used : FrameTransport(org.apache.qpid.tests.protocol.v0_8.FrameTransport) ConfirmSelectOkBody(org.apache.qpid.server.protocol.v0_8.transport.ConfirmSelectOkBody) Interaction(org.apache.qpid.tests.protocol.v0_8.Interaction) BasicAckBody(org.apache.qpid.server.protocol.v0_8.transport.BasicAckBody) Test(org.junit.Test) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest)

Aggregations

BasicAckBody (org.apache.qpid.server.protocol.v0_8.transport.BasicAckBody)3 SpecificationTest (org.apache.qpid.tests.protocol.SpecificationTest)3 FrameTransport (org.apache.qpid.tests.protocol.v0_8.FrameTransport)3 Interaction (org.apache.qpid.tests.protocol.v0_8.Interaction)3 Test (org.junit.Test)3 ConfirmSelectOkBody (org.apache.qpid.server.protocol.v0_8.transport.ConfirmSelectOkBody)2 BasicNackBody (org.apache.qpid.server.protocol.v0_8.transport.BasicNackBody)1 ChannelOpenOkBody (org.apache.qpid.server.protocol.v0_8.transport.ChannelOpenOkBody)1 TxSelectOkBody (org.apache.qpid.server.protocol.v0_8.transport.TxSelectOkBody)1