Search in sources :

Example 1 with BasicReturnBody

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

the class BasicTest method publishUnrouteableMandatoryMessage.

@Test
@SpecificationTest(section = "1.8.3.7", description = "This flag [mandatory] tells the server how to react if the message cannot be routed to a " + "queue. If this flag is set, the server will return an unroutable message with a " + "Return method.")
public void publishUnrouteableMandatoryMessage() throws Exception {
    try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
        final Interaction interaction = transport.newInteraction();
        String messageContent = "Test";
        BasicReturnBody returned = interaction.openAnonymousConnection().channel().open().consumeResponse(ChannelOpenOkBody.class).basic().publishExchange("").publishRoutingKey("unrouteable").publishMandatory(true).content(messageContent).publishMessage().consumeResponse().getLatestResponse(BasicReturnBody.class);
        assertThat(returned.getReplyCode(), is(equalTo(ErrorCodes.NO_ROUTE)));
        ContentBody content = interaction.consumeResponse(ContentHeaderBody.class).consumeResponse().getLatestResponse(ContentBody.class);
        assertThat(getContent(content), is(equalTo(messageContent)));
        interaction.channel().close().consumeResponse(ChannelCloseOkBody.class);
    }
}
Also used : BasicReturnBody(org.apache.qpid.server.protocol.v0_8.transport.BasicReturnBody) ContentBody(org.apache.qpid.server.protocol.v0_8.transport.ContentBody) AMQShortString(org.apache.qpid.server.protocol.v0_8.AMQShortString) Test(org.junit.Test) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest)

Aggregations

AMQShortString (org.apache.qpid.server.protocol.v0_8.AMQShortString)1 BasicReturnBody (org.apache.qpid.server.protocol.v0_8.transport.BasicReturnBody)1 ContentBody (org.apache.qpid.server.protocol.v0_8.transport.ContentBody)1 SpecificationTest (org.apache.qpid.tests.protocol.SpecificationTest)1 Test (org.junit.Test)1