Example usage for org.springframework.amqp.rabbit.core BatchingRabbitTemplate receiveAndConvert

List of usage examples for org.springframework.amqp.rabbit.core BatchingRabbitTemplate receiveAndConvert

Introduction

In this page you can find the example usage for org.springframework.amqp.rabbit.core BatchingRabbitTemplate receiveAndConvert.

Prototype

@Override
    @Nullable
    public Object receiveAndConvert(String queueName) throws AmqpException 

Source Link

Usage

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

@Test
public void testSimpleBatchGZippedWithEncodingInflated() throws Exception {
    BatchingStrategy batchingStrategy = new SimpleBatchingStrategy(2, Integer.MAX_VALUE, 30000);
    BatchingRabbitTemplate template = new BatchingRabbitTemplate(batchingStrategy, this.scheduler);
    template.setConnectionFactory(this.connectionFactory);
    template.setBeforePublishPostProcessors(new GZipPostProcessor());
    template.setAfterReceivePostProcessors(new DelegatingDecompressingPostProcessor());
    MessageProperties props = new MessageProperties();
    props.setContentEncoding("foo");
    Message message = new Message("foo".getBytes(), props);
    template.send("", ROUTE, message);
    message = new Message("bar".getBytes(), props);
    template.send("", ROUTE, message);
    Thread.sleep(100);/*from   w  ww  .  j a v a 2  s.c o m*/
    byte[] out = (byte[]) template.receiveAndConvert(ROUTE);
    assertNotNull(out);
    assertEquals("\u0000\u0000\u0000\u0003foo\u0000\u0000\u0000\u0003bar", new String(out));
}