title: Writing sample producer and consumer with spring integration and rabbit mq
body: <p>I try to write sample producer &amp; consumer with SpringIntegration and RabbitMQ.</p>
  
  <p>Here My rabbit.xml config file:</p>
  
  <pre><code>&lt;rabbit:connection-factory id="connectionFactory" /&gt;
  &lt;rabbit:template id="amqpTemplate" connection-factory="connectionFactory" /&gt;
  &lt;rabbit:admin connection-factory="connectionFactory" /&gt;
  &lt;rabbit:queue name="queue.request" /&gt;
  &lt;rabbit:queue name="queue.response" /&gt;
  &lt;rabbit:direct-exchange name="exchange.main"&gt;
      &lt;rabbit:bindings&gt;
          &lt;rabbit:binding queue="queue.request" key="binding.queue.request"/&gt;
          &lt;rabbit:binding queue="queue.response" key="binding.queue.response" /&gt;
      &lt;/rabbit:bindings&gt;
  &lt;/rabbit:direct-exchange&gt;
  </code></pre>
  
  <p>and </p>
  
  <p>producer.xml file:</p>
  
  <pre><code>&lt;context:annotation-config /&gt;
  &lt;import resource="classpath:META-INF/zcore/integration/rabbit.xml" /&gt;
  &lt;int:channel id="request" /&gt;
  &lt;int:channel id="response" /&gt;
  &lt;int-amqp:outbound-channel-adapter channel="request" amqp-template="amqpTemplate" 
      exchange-name="exchange.main" routing-key="binding.queue.request"       
  &lt;int-amqp:inbound-channel-adapter channel="response" queue-names="queue.response"
       connection-factory="connectionFactory" /&gt;  
  &lt;int:gateway id="baseGateway" service-interface="org.zcoreframework.integration.gateway.BaseGateway"
      default-request-channel="request" default-reply-channel="response" /&gt;   
  </code></pre>
  
  <p>and</p>
  
  <p>consumer.xml file:</p>
  
  <pre><code>&lt;import resource="classpath:META-INF/zcore/integration/rabbit.xml" /&gt;
  &lt;context:annotation-config /&gt;
  &lt;context:component-scan base-package="org.zcoreframework" /&gt;
  &lt;int:channel id="request" /&gt; 
  &lt;int:channel id="response" /&gt;
  &lt;int-amqp:inbound-channel-adapter channel="request" queue-names="queue.request"
       connection-factory="connectionFactory" /&gt;  
  &lt;int-amqp:outbound-channel-adapter channel="response" amqp-template="amqpTemplate" 
      exchange-name="exchange.main" routing-key="binding.queue.response" /&gt;
  &lt;int:service-activator ref="messageConsumer" method="onMessage" input-channel="request"
      output-channel="response" /&gt;
  </code></pre>
  
  <p>and I wrote this snipped code for send message and get the response:</p>
  
  <pre><code>@Autowired
  BaseGateway baseGateway;
  
  @Test
  public void testHelloWorld() {
  
          CallMethodMessage callMethodMessage = new CallMethodMessage();
          callMethodMessage.setMethod("test");
          callMethodMessage.setArgs(null);
          System.out.print("send &amp; receive ");            
          ReturnModel returnModel = this.baseGateway.SendWait(callMethodMessage);         
          //this.baseGateway.FireForget(callMethodMessage);
  }
  </code></pre>
  
  <p>and this is my interface </p>
  
  <pre><code>public interface BaseGateway {
  
      @Gateway
      public void FireForget(CallMethodMessage method);
  
      @Gateway
      public ReturnModel SendWait(CallMethodMessage method);
  
  }
  </code></pre>
  
  <p>OK now I run consumer separately then for the first one I run producer with method FireForget and everything is OK, cosumer gets it and prints a message but when I run with SendWait method the cosumer gets it but not return anything and the producer waits to get the response, How can I handle this problem?</p>