Example usage for org.springframework.amqp.rabbit.core RabbitTemplate setAfterReceivePostProcessors

List of usage examples for org.springframework.amqp.rabbit.core RabbitTemplate setAfterReceivePostProcessors

Introduction

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

Prototype

public void setAfterReceivePostProcessors(MessagePostProcessor... afterReceivePostProcessors) 

Source Link

Document

Set a MessagePostProcessor that will be invoked immediately after a Channel#basicGet() and before any message conversion is performed.

Usage

From source file:org.springframework.cloud.stream.binder.rabbit.RabbitBinderTests.java

@Override
public Spy spyOn(final String queue) {
    final RabbitTemplate template = new RabbitTemplate(this.rabbitAvailableRule.getResource());
    template.setAfterReceivePostProcessors(new DelegatingDecompressingPostProcessor());
    return new Spy() {

        @Override//  ww w. j a  va  2s . c o  m
        public Object receive(boolean expectNull) throws Exception {
            if (expectNull) {
                Thread.sleep(50);
                return template.receiveAndConvert(new RabbitConsumerProperties().getPrefix() + queue);
            }
            Object bar = null;
            int n = 0;
            while (n++ < 100 && bar == null) {
                bar = template.receiveAndConvert(new RabbitConsumerProperties().getPrefix() + queue);
                Thread.sleep(100);
            }
            assertThat(n).isLessThan(100).withFailMessage("Message did not arrive in RabbitMQ");
            return bar;
        }

    };
}

From source file:org.springframework.xd.dirt.integration.bus.rabbit.RabbitMessageBusTests.java

@Override
public Spy spyOn(final String queue) {
    final RabbitTemplate template = new RabbitTemplate(this.rabbitAvailableRule.getResource());
    template.setAfterReceivePostProcessors(new DelegatingDecompressingPostProcessor());
    return new Spy() {

        @Override//  w ww  . jav a 2 s .co m
        public Object receive(boolean expectNull) throws Exception {
            if (expectNull) {
                Thread.sleep(50);
                return template.receiveAndConvert("xdbus." + queue);
            }
            Object bar = null;
            int n = 0;
            while (n++ < 100 && bar == null) {
                bar = template.receiveAndConvert("xdbus." + queue);
                Thread.sleep(100);
            }
            assertTrue("Message did not arrive in RabbitMQ", n < 100);
            return bar;
        }

    };
}