title: How to work with rabbitTemplate receiveAndReply
body: <p>I have just started experimenting with Spring and rabbitMQ.
  I would like to create a microsevice infrastructure with rabbit and spring,
  I have been following <a href="https://spring.io/guides/gs/messaging-rabbitmq/" rel="nofollow">Spring boot tutorial</a></p>
  
  <p>But it is very simplistic. As well I am looking at the documentation (<a href="http://docs.spring.io/spring-amqp/docs/1.3.5.RELEASE/reference/html/amqp.html#request-reply" rel="nofollow">springs</a>, <a href="http://www.rabbitmq.com/tutorials/tutorial-six-java.html" rel="nofollow">Rabbit</a>) for how to create an RPC, i understand the Rabbits approach, but i would like to leverage Spring template to save me the boilerplate.</p>
  
  <p>I just cant seem to understand where to register the reciveAndReplay callback at.</p>
  
  <p>I tried doing this:</p>
  
  <p>sending</p>
  
  <blockquote>
  <pre><code>    System.out.println("Sending message...");
      Object convertSendAndReceive = rabbitTemplate.convertSendAndReceive("spring-boot", "send and recive: sent");
      System.out.println("GOT " + convertSendAndReceive); //is null        
  </code></pre>
  </blockquote>
  
  <p>receiving</p>
  
  <blockquote>
  <pre><code>@Component
  public class Receiver {
  @Autowired
  RabbitTemplate rabbitTemplate;
  public void receiveMessage(String message) {
      this.rabbitTemplate.receiveAndReply("spring-boot", (Message)-&gt;{
          return "return this statement";
      });
  }
  }
  </code></pre>
  </blockquote>
  
  <p>But its not a big surprise this doesn't work the message is received but nothing comes back. I assume that this needs to be registered somewhere in the factory/template at the bean creation level but i don't seem to understand where and sadly the documentation is unclear.</p>