title: Spring Cloud Stream: @StreamListener processing messages twice
body: <p>I'm using Spring Cloud Stream (Edgware.SR5) with Spring Boot (1.5.10.RELEASE). My @StreamListener is processing twice every message it receives.</p>
  
  <p>The idea of the example is to publish a message in a queue and the process it.</p>
  
  <p>Service:</p>
  
  <pre><code>@EnableBinding(ExampleBindings.class)
  @Service
  public class ExampleService {
  
      @Publisher(channel = ExampleBindings.OUTPUT)
      public String queue(String message){
          return message;
      }
  
      @StreamListener(ExampleBindings.INPUT)
      public void dequeue(String message){
          System.out.println("New message: " + message);
      }
  }
  </code></pre>
  
  <p>Bindings:</p>
  
  <pre><code>public interface ExampleBindings {
  
      String INPUT = "input1";
      String OUTPUT = "output1";
  
      @Input(ExampleBindings.INPUT)
      SubscribableChannel input();
  
      @Output(ExampleBindings.OUTPUT)
      MessageChannel output();
  }
  </code></pre>
  
  <p>application.properties:</p>
  
  <pre><code>spring.cloud.stream.default.group=group1
  spring.cloud.stream.default.binder=binder1
  
  spring.cloud.stream.bindings.input1.destination=dest_1
  spring.cloud.stream.bindings.output1.destination=dest_1
  
  spring.cloud.stream.binders.binder1.type=rabbit
  spring.cloud.stream.binders.binder1.environment.spring.rabbitmq.host=localhost
  </code></pre>
  
  <p>Configuration (for injecting proxied service in the test):</p>
  
  <pre><code>@Configuration
  public class ExampleConfig {
  
      @Bean
      public PublisherAnnotationBeanPostProcessor publisherAnnotationBeanPostProcessor(){
           PublisherAnnotationBeanPostProcessor publisherAnnotationBeanPostProcessor =
              new PublisherAnnotationBeanPostProcessor();
          publisherAnnotationBeanPostProcessor.setProxyTargetClass(true);
          return publisherAnnotationBeanPostProcessor;
      }
  }
  </code></pre>
  
  <p>Test:</p>
  
  <pre><code>@RunWith(SpringRunner.class)
  @SpringBootTest
  public class ExampleServiceTest {
  
      @Autowired
      private ExampleService exampleService;
  
      @Test
      public void testQueue() throws InterruptedException {
          exampleService.queue("Hello!");
          Thread.sleep(1000);//Wait for message processing
          System.out.println("Ready!");
      }
  }
  </code></pre>
  
  <p>I'm having the following output:</p>
  
  <pre><code>17:19:10.230 [dest1.group1-2] DEBUG o.s.c.s.b.StreamListenerMessageHandler - org.springframework.cloud.stream.binding.StreamListenerMessageHandler@575c3e9b received message: GenericMessage [payload=Hello!, headers={amqp_receivedDeliveryMode=PERSISTENT, amqp_receivedRoutingKey=dest1, amqp_receivedExchange=dest1, amqp_deliveryTag=1, amqp_consumerQueue=dest1.group1, amqp_redelivered=false, id=2f22ce16-bb5a-350c-8b3d-e6c898760888, amqp_consumerTag=amq.ctag-sxu6zQHJTGrsazfwbmol9Q, contentType=text/plain, timestamp=1547583550230}]
  New message: Hello!
  17:19:10.231 [dest1.group1-1] DEBUG o.s.c.s.b.StreamListenerMessageHandler - handler 'org.springframework.cloud.stream.binding.StreamListenerMessageHandler@575c3e9b' produced no reply for request Message: GenericMessage [payload=Hello!, headers={amqp_receivedDeliveryMode=PERSISTENT, amqp_receivedRoutingKey=dest1, amqp_receivedExchange=dest1, amqp_deliveryTag=1, amqp_consumerQueue=dest1.group1, amqp_redelivered=false, id=788e8bbf-4ae4-86cc-0859-d4f153cb5807, amqp_consumerTag=amq.ctag-fV0aaDzYUZfq08JsODq6pA, contentType=text/plain, timestamp=1547583550230}]
  17:19:10.231 [dest1.group1-1] DEBUG o.s.i.channel.DirectChannel - postSend (sent=true) on channel 'input1', message: GenericMessage [payload=Hello!, headers={amqp_receivedDeliveryMode=PERSISTENT, amqp_receivedRoutingKey=dest1, amqp_receivedExchange=dest1, amqp_deliveryTag=1, amqp_consumerQueue=dest1.group1, amqp_redelivered=false, id=788e8bbf-4ae4-86cc-0859-d4f153cb5807, amqp_consumerTag=amq.ctag-fV0aaDzYUZfq08JsODq6pA, contentType=text/plain, timestamp=1547583550230}]
  New message: Hello!
  17:19:10.232 [dest1.group1-2] DEBUG o.s.c.s.b.StreamListenerMessageHandler - handler 'org.springframework.cloud.stream.binding.StreamListenerMessageHandler@575c3e9b' produced no reply for request Message: GenericMessage [payload=Hello!, headers={amqp_receivedDeliveryMode=PERSISTENT, amqp_receivedRoutingKey=dest1, amqp_receivedExchange=dest1, amqp_deliveryTag=1, amqp_consumerQueue=dest1.group1, amqp_redelivered=false, id=2f22ce16-bb5a-350c-8b3d-e6c898760888, amqp_consumerTag=amq.ctag-sxu6zQHJTGrsazfwbmol9Q, contentType=text/plain, timestamp=1547583550230}]
  17:19:10.232 [dest1.group1-2] DEBUG o.s.i.channel.DirectChannel - postSend (sent=true) on channel 'input1', message: GenericMessage [payload=Hello!, headers={amqp_receivedDeliveryMode=PERSISTENT, amqp_receivedRoutingKey=dest1, amqp_receivedExchange=dest1, amqp_deliveryTag=1, amqp_consumerQueue=dest1.group1, amqp_redelivered=false, id=2f22ce16-bb5a-350c-8b3d-e6c898760888, amqp_consumerTag=amq.ctag-sxu6zQHJTGrsazfwbmol9Q, contentType=text/plain, timestamp=1547583550230}]
  Ready!
  </code></pre>
  
  <p>I can't figure out what is the problem with my configuration or if it is some bug, any advice?</p>
  
  <p>Thanks!</p>
  
  <p>EDITED:</p>
  
  <p>I uploaded a (non) working example <a href="https://github.com/italktothewind/spring-cloud-examples" rel="nofollow noreferrer">here</a></p>
  
  <p>You can create a RabbitMQ instance using:</p>
  
  <pre><code>docker run -p 5672:5672 -p 15672:15672 rabbitmq:3-management
  </code></pre>