0
votes

I have created route that accept request from multiple producers and send to a remote server by using netty4 with request-response. However, when camel is sending a request to remote server and waiting for response, next incoming request is received and want to send to remote server but got IOException as camel cannot receive response.

So, how to set Camel-Netty4 send request and wait for response before send next.

The route configuration: from("direct:DirectProcessOut?block=true") .to("netty4:tcp://192.168.1.2:8000?sync=true&synchronous=true&reuseChannel=true")

1

1 Answers

0
votes

I actually ran into a similar issue trying to send out several messages at a time based on rows in a database table. The calls wouldn't wait for each other to complete and essentially stepped on each other and either hung or blew up.

The solution I eventually found was to use a message queue. Take in your requests and route them into a single activemq route.

So something like:

<camelContext xmlns="http://camel.apache.org/schema/blueprint">
    <route>
       <from uri="direct:direct:DirectProcessOut"/>
       <to uri="activemq://processOutQueue"/>
    </route>
</camelContext>
<camelContext xmlns="http://camel.apache.org/schema/blueprint">
    <route>
       <from uri="activemq://processOutQueue"/>
       <to uri="netty4:tcp://192.168.1.2:8000?sync=true&amp;synchronous=true&amp;reuseChannel=true"/>
    </route>
</camelContext>

My case was a little different, so I'm not sure if this will preserve your message you want to send. But hopefully it gives you a place to start.