title: Receiving messages from tcp server with Citrus framework and Spring Integration times out
body: <p>I am trying to test a simple tcp send/receive sequence making use of citrus framework. I am able to send messages fine but receiving messages proves problematic. Basically, the reply is not detected by citrus and citrus then times out.</p>
  
  <p><strong>Citrus bean configuration:</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans xmlns="http://www.springframework.org/schema/beans"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xmlns:citrus="http://www.citrusframework.org/schema/config"
     xmlns:int="http://www.springframework.org/schema/integration"
     xmlns:int-ip="http://www.springframework.org/schema/integration/ip"
     xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
  
      http://www.citrusframework.org/schema/config http://www.citrusframework.org/schema/config/citrus-config.xsd
      http://www.springframework.org/schema/integration  http://www.springframework.org/schema/integration/spring-integration.xsd
      http://www.springframework.org/schema/integration/ip  http://www.springframework.org/schema/integration/ip/spring-integration-ip.xsd"&gt;
  
  &lt;citrus:channel-endpoint id="citrusServiceInputEndpoint"
                           channel-name="input" /&gt;
  
  &lt;citrus:channel-endpoint id="citrusServiceRepliesEndpoint"
                           channel-name="replies" /&gt;
  
  &lt;int-ip:tcp-connection-factory id="client"
                                 type="client" host="localhost" port="9123" single-use="false"
                                 so-timeout="10000" using-nio="true" /&gt;
  
  &lt;int:channel id="input" /&gt;
  
  &lt;int:channel id="replies"&gt;
      &lt;int:queue capacity="10" /&gt;
  &lt;/int:channel&gt;
  
  &lt;int-ip:tcp-outbound-channel-adapter
          id="outboundClient" channel="input" connection-factory="client" /&gt;
  
  &lt;int-ip:tcp-inbound-channel-adapter
          id="inboundClient" channel="replies" connection-factory="client" /&gt;
  </code></pre>
  
  <p></p>
  
  <p><strong>Citrus test case:</strong></p>
  
  <pre><code>@Test
  @CitrusTest(name = "sendSpringIntegrationMessageTest")
  public void sendSpringIntegrationMessageTest() throws Exception {
      send("citrusServiceInputEndpoint").payload("Req");
      receive("citrusServiceRepliesEndpoint").payload("Rsp");
  }
  </code></pre>
  
  <p>Im using a simple netcat server to test:</p>
  
  <pre><code>nc -kl 9123
  </code></pre>
  
  <p>When running the test case, the "Req" text arrives fine on netcat. However, when typing "Rsp" on netcat, the data does not arrive at the citrus test. After about 5 seconds, the test case fails with the following message:</p>
  
  <pre><code>com.consol.citrus.exceptions.TestCaseFailedException: Test case failed
  
  at com.consol.citrus.TestCase.executeAction(TestCase.java:218)
  at com.consol.citrus.TestCase.doExecute(TestCase.java:139)
  at com.consol.citrus.actions.AbstractTestAction.execute(AbstractTestAction.java:42)
  at com.consol.citrus.Citrus.run(Citrus.java:243)
  at com.consol.citrus.dsl.junit.JUnit4CitrusTest.invokeTestMethod(JUnit4CitrusTest.java:90)
  at com.consol.citrus.dsl.junit.JUnit4CitrusTestDesigner.invokeTestMethod(JUnit4CitrusTestDesigner.java:68)
  at com.consol.citrus.dsl.junit.JUnit4CitrusTest.run(JUnit4CitrusTest.java:71)
  at com.consol.citrus.junit.CitrusJUnit4Runner$InvokeRunMethod.evaluate(CitrusJUnit4Runner.java:212)
  at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:75)
  at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:86)
  at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:84)
  at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
  at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:254)
  at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:89)
  at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
  at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
  at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
  at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
  at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
  at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
  at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
  at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
  at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
  at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
  at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:193)
  at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
  at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69)
  at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:234)
  at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:74)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.lang.reflect.Method.invoke(Method.java:483)
  at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
  Caused by: com.consol.citrus.exceptions.ActionTimeoutException: Action timeout while receiving message from channel 'replies'
      at com.consol.citrus.channel.ChannelConsumer.receive(ChannelConsumer.java:97)
      at com.consol.citrus.messaging.AbstractSelectiveMessageConsumer.receive(AbstractSelectiveMessageConsumer.java:50)
      at com.consol.citrus.actions.ReceiveMessageAction.receive(ReceiveMessageAction.java:146)
      at com.consol.citrus.actions.ReceiveMessageAction.doExecute(ReceiveMessageAction.java:125)
      at com.consol.citrus.actions.AbstractTestAction.execute(AbstractTestAction.java:42)
      at com.consol.citrus.TestCase.executeAction(TestCase.java:211)
      ... 33 more
  </code></pre>
  
  <p>So basically Citrus didn't receive the response. Note that I have to define a queue for the replies channel as this is what Citrus expects, the reply channel must implement Interface PollableChannel. </p>
  
  <p>Please help me understand as to why the data is not received by Citrus from the queue?</p>