Hi James,

I hope I understand your scenario correctly. Here are a few thoughts. I assume 
want to use camel-netty [1] to send messages to your sever (if you have your 
own code that does that, you can use it too, but you'd have to write your own 
Processor or Component). Iiuic, your scenario is converting a 2x in-only to a 
1x in-out async mep. You should then treat your exchange as an async in-out and 
let your framework (Camel) decompose it and compose it back again. I would not 
keep threads blocked so I believe your best bet is using the Camel async 
messaging [2] and Futures (look at the examples using asyncSend* and 
asyncCallback*). The issue is that Camel is stateless so you'll need a 
correlationId, which you must have already and something to keep your state. A 
good bet would be jms [3], or you could write your own. If you used jms you 
would need to use both a correlationId and a replyTo queue.

from("jms:request-queue").to("netty:output?=correlationId");
from("netty:input).to("jms:replyTo-queue")

You may have to play a bit with the correlationId and if you cannot use the 
same you can do a second transformation/correlation using a claim-check sort of 
pattern. If you don't want to use jms you can implement your own (in memory) 
persistence and correlation. You can also use a resequencer [4] if you want to 
enforce the order. If you use asyncCallback, you get the replies when they 
become available, and you can control that. 

It's an interesting scenario, I'll definitely give it more thought, but I hope 
this helps.
Hadrian


[1] http://camel.apache.org/netty.html
[2] http://camel.apache.org/async.html
[3] http://camel.apache.org/jms.html
[4] http://camel.apache.org/resequencer.html


On Aug 6, 2011, at 8:37 AM, James Carman wrote:

> We have a server that supports a socket-based protocol.  However, it's
> not a synchronous situation.  I send a message over the output stream
> of the socket and a it goes over to the server to processed.  The
> reply message will be received at some later time on the socket's
> input stream, not necessarily in the same order they were sent.  Now,
> I'd like to turn this into a request/reply exchange using Camel.  I
> plan on using Netty to implement the socket protocol stuff.  However,
> I'm not exactly sure how to go about making the requesting threads
> wait while my server does its processing.  It appears that Camel
> already has stuff built-in to handle this.  I'm just having trouble
> setting up the route properly.

Reply via email to