Example usage for org.springframework.amqp.rabbit.support Delivery getProperties

List of usage examples for org.springframework.amqp.rabbit.support Delivery getProperties

Introduction

In this page you can find the example usage for org.springframework.amqp.rabbit.support Delivery getProperties.

Prototype

public BasicProperties getProperties() 

Source Link

Document

Retrieve the message properties.

Usage

From source file:org.springframework.amqp.rabbit.listener.BlockingQueueConsumer.java

/**
 * If this is a non-POISON non-null delivery simply return it. If this is
 * POISON we are in shutdown mode, throw shutdown. If delivery is null, we
 * may be in shutdown mode. Check and see.
 * //  w  w w.  ja  v  a2  s.c o  m
 * @throws InterruptedException
 */
private Message handle(Delivery delivery) throws InterruptedException {
    if ((delivery == null && shutdown != null)) {
        throw shutdown;
    }
    if (delivery == null) {
        return null;
    }
    byte[] body = delivery.getBody();
    Envelope envelope = delivery.getEnvelope();

    MessageProperties messageProperties = this.messagePropertiesConverter
            .toMessageProperties(delivery.getProperties(), envelope, "UTF-8");
    messageProperties.setMessageCount(0);
    Message message = new Message(body, messageProperties);
    if (logger.isDebugEnabled()) {
        logger.debug("Received message: " + message);
    }
    deliveryTags.add(messageProperties.getDeliveryTag());
    int retryTimes = getRequeueTimes(message);
    retryDeliveryTags.put(messageProperties.getDeliveryTag(), ++retryTimes);
    return message;
}