Search in sources :

Example 46 with GetResponse

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;
}
Also used : GetResponse(com.rabbitmq.client.GetResponse)

Example 47 with GetResponse

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);
}
Also used : GetResponse(com.rabbitmq.client.GetResponse) Test(org.junit.Test)

Example 48 with GetResponse

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);
}
Also used : GetResponse(com.rabbitmq.client.GetResponse) Test(org.junit.Test)

Example 49 with GetResponse

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());
}
Also used : BasicProperties(com.rabbitmq.client.AMQP.BasicProperties) Envelope(com.rabbitmq.client.Envelope) GetResponse(com.rabbitmq.client.GetResponse)

Example 50 with GetResponse

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;
}
Also used : GetResponse(com.rabbitmq.client.GetResponse)

Aggregations

GetResponse (com.rabbitmq.client.GetResponse)55 Test (org.junit.Test)27 Channel (com.rabbitmq.client.Channel)10 IOException (java.io.IOException)10 Envelope (com.rabbitmq.client.Envelope)8 Connection (com.rabbitmq.client.Connection)7 Message (de.gessnerfl.rabbitmq.queue.management.model.Message)6 HashMap (java.util.HashMap)6 AMQP (com.rabbitmq.client.AMQP)5 LongString (com.rabbitmq.client.LongString)5 BasicProperties (com.rabbitmq.client.AMQP.BasicProperties)4 BasicProperties (de.gessnerfl.rabbitmq.queue.management.model.BasicProperties)4 RMQDestination (com.rabbitmq.jms.admin.RMQDestination)3 ArrayList (java.util.ArrayList)3 HashSet (java.util.HashSet)3 List (java.util.List)3 Map (java.util.Map)3 Queue (javax.jms.Queue)3 QueueSender (javax.jms.QueueSender)3 QueueSession (javax.jms.QueueSession)3