use of com.rabbitmq.client.GetResponse in project rabbitmq-java-client by rabbitmq.
the class Transactions method basicGet.
private GetResponse basicGet(boolean noAck) throws IOException {
GetResponse r = channel.basicGet(Q, noAck);
latestTag = (r == null) ? 0L : r.getEnvelope().getDeliveryTag();
return r;
}
use of com.rabbitmq.client.GetResponse in project rabbitmq-java-client by rabbitmq.
the class DurableBindingLifecycle method defaultBindingRecovery.
/**
* This tests whether the default bindings for durable queues
* are recovered properly.
*
* The idea is to create a durable queue, nuke the server and then
* publish a message to it using the queue name as a routing key
*/
@Test
public void defaultBindingRecovery() throws IOException, TimeoutException {
declareDurableQueue(Q);
restart();
basicPublishVolatile("", Q);
GetResponse response = channel.basicGet(Q, true);
assertNotNull("The initial response SHOULD NOT be null", response);
deleteQueue(Q);
}
use of com.rabbitmq.client.GetResponse in project rabbitmq-java-client by rabbitmq.
the class Firehose method firehose.
@Test
public void firehose() throws IOException {
publishGet("not traced");
enable();
GetResponse msg = publishGet("traced");
disable();
publishGet("not traced");
GetResponse publish = basicGet(firehose);
GetResponse deliver = basicGet(firehose);
assertNotNull(publish);
assertNotNull(deliver);
assertDelivered(firehose, 0);
// We don't test everything, that would be a bit OTT
checkHeaders(publish.getProps().getHeaders());
Map<String, Object> delHeaders = deliver.getProps().getHeaders();
checkHeaders(delHeaders);
assertNotNull(delHeaders.get("redelivered"));
assertEquals(msg.getBody().length, publish.getBody().length);
assertEquals(msg.getBody().length, deliver.getBody().length);
}
use of com.rabbitmq.client.GetResponse in project beam by apache.
the class RabbitMqMessage method serializableDeliveryOf.
/**
* Make delivery serializable by cloning all non-serializable values into serializable ones. If it
* is not possible, initial delivery is returned and error message is logged
*
* @param processed
* @return
*/
private static GetResponse serializableDeliveryOf(GetResponse processed) {
// All content of envelope is serializable, so no problem there
Envelope envelope = processed.getEnvelope();
// in basicproperties, there may be LongString, which are *not* serializable
BasicProperties properties = processed.getProps();
BasicProperties nextProperties = new BasicProperties.Builder().appId(properties.getAppId()).clusterId(properties.getClusterId()).contentEncoding(properties.getContentEncoding()).contentType(properties.getContentType()).correlationId(properties.getCorrelationId()).deliveryMode(properties.getDeliveryMode()).expiration(properties.getExpiration()).headers(serializableHeaders(properties.getHeaders())).messageId(properties.getMessageId()).priority(properties.getPriority()).replyTo(properties.getReplyTo()).timestamp(properties.getTimestamp()).type(properties.getType()).userId(properties.getUserId()).build();
return new GetResponse(envelope, nextProperties, processed.getBody(), processed.getMessageCount());
}
use of com.rabbitmq.client.GetResponse in project pinpoint by naver.
the class TestMessagePuller method pullMessage.
public <T> T pullMessage(MessageConverter<T> messageConverter, String queueName, boolean autoAck) throws IOException {
GetResponse response = channel.basicGet(queueName, autoAck);
if (response == null) {
return null;
}
propagationMarker.mark();
byte[] body = response.getBody();
T message = messageConverter.convertMessage(body);
if (!autoAck) {
channel.basicAck(response.getEnvelope().getDeliveryTag(), false);
}
return message;
}
Aggregations