Example usage for org.springframework.amqp.rabbit.support DefaultMessagePropertiesConverter DefaultMessagePropertiesConverter

List of usage examples for org.springframework.amqp.rabbit.support DefaultMessagePropertiesConverter DefaultMessagePropertiesConverter

Introduction

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

Prototype

public DefaultMessagePropertiesConverter() 

Source Link

Document

Construct an instance where LongString s will be returned unconverted when longer than 1024 bytes.

Usage

From source file:org.springframework.amqp.rabbit.core.RabbitTemplateIntegrationTests.java

@Test
public void testSendAndReceiveInCallback() throws Exception {
    template.convertAndSend(ROUTE, "message");
    final MessagePropertiesConverter messagePropertiesConverter = new DefaultMessagePropertiesConverter();
    String result = template.execute(new ChannelCallback<String>() {
        public String doInRabbit(Channel channel) throws Exception {
            // We need noAck=false here for the message to be expicitly
            // acked
            GetResponse response = channel.basicGet(ROUTE, false);
            MessageProperties messageProps = messagePropertiesConverter.toMessageProperties(response.getProps(),
                    response.getEnvelope(), "UTF-8");
            // Explicit ack
            channel.basicAck(response.getEnvelope().getDeliveryTag(), false);
            return (String) new SimpleMessageConverter()
                    .fromMessage(new Message(response.getBody(), messageProps));
        }/*from w w  w .  j  a  v  a  2  s. c  o m*/
    });
    assertEquals("message", result);
    result = (String) template.receiveAndConvert(ROUTE);
    assertEquals(null, result);
}