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);
}
}
Aggregations