Example usage for org.springframework.amqp.core MessageProperties setConsumerQueue

List of usage examples for org.springframework.amqp.core MessageProperties setConsumerQueue

Introduction

In this page you can find the example usage for org.springframework.amqp.core MessageProperties setConsumerQueue.

Prototype

public void setConsumerQueue(String consumerQueue) 

Source Link

Usage

From source file:org.springframework.integration.amqp.inbound.AmqpMessageSource.java

@Override
protected AbstractIntegrationMessageBuilder<Object> doReceive() {
    Connection connection = this.connectionFactory.createConnection(); // NOSONAR - RabbitUtils
    Channel channel = connection.createChannel(this.transacted);
    try {//from  www  .j  av  a2s . c om
        GetResponse resp = channel.basicGet(this.queue, false);
        if (resp == null) {
            RabbitUtils.closeChannel(channel);
            RabbitUtils.closeConnection(connection);
            return null;
        }
        AcknowledgmentCallback callback = this.ackCallbackFactory
                .createCallback(new AmqpAckInfo(connection, channel, this.transacted, resp));
        MessageProperties messageProperties = this.propertiesConverter.toMessageProperties(resp.getProps(),
                resp.getEnvelope(), StandardCharsets.UTF_8.name());
        messageProperties.setConsumerQueue(this.queue);
        Map<String, Object> headers = this.headerMapper.toHeadersFromRequest(messageProperties);
        org.springframework.amqp.core.Message amqpMessage = new org.springframework.amqp.core.Message(
                resp.getBody(), messageProperties);
        Object payload = this.messageConverter.fromMessage(amqpMessage);
        AbstractIntegrationMessageBuilder<Object> builder = getMessageBuilderFactory().withPayload(payload)
                .copyHeaders(headers)
                .setHeader(IntegrationMessageHeaderAccessor.ACKNOWLEDGMENT_CALLBACK, callback);
        if (this.rawMessageHeader) {
            builder.setHeader(AmqpMessageHeaderErrorMessageStrategy.AMQP_RAW_MESSAGE, amqpMessage);
        }
        return builder;
    } catch (IOException e) {
        RabbitUtils.closeChannel(channel);
        RabbitUtils.closeConnection(connection);
        throw RabbitExceptionTranslator.convertRabbitAccessException(e);
    }
}