use of org.apache.qpid.server.protocol.v0_8.transport.BasicGetOkBody in project qpid-broker-j by apache.
the class BasicTest method get.
@Test
@SpecificationTest(section = "1.8.3.10", description = "direct access to a queue")
public void get() throws Exception {
String messageContent = "message";
getBrokerAdmin().putMessageOnQueue(BrokerAdmin.TEST_QUEUE_NAME, messageContent);
try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
final Interaction interaction = transport.newInteraction();
BasicGetOkBody response = interaction.openAnonymousConnection().channel().open().consumeResponse(ChannelOpenOkBody.class).basic().getQueueName(BrokerAdmin.TEST_QUEUE_NAME).get().consumeResponse().getLatestResponse(BasicGetOkBody.class);
long deliveryTag = response.getDeliveryTag();
ContentBody content = interaction.consumeResponse(ContentHeaderBody.class).consumeResponse().getLatestResponse(ContentBody.class);
String receivedContent = getContent(content);
assertThat(receivedContent, is(equalTo(messageContent)));
assertThat(getBrokerAdmin().getQueueDepthMessages(BrokerAdmin.TEST_QUEUE_NAME), is(equalTo(1)));
interaction.basic().ackDeliveryTag(deliveryTag).ack().channel().close().consumeResponse(ChannelCloseOkBody.class);
assertThat(getBrokerAdmin().getQueueDepthMessages(BrokerAdmin.TEST_QUEUE_NAME), is(equalTo(0)));
}
}
Aggregations