You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by andlu702 <an...@r2m.se> on 2012/01/27 16:32:53 UTC

Message-dependent sync with MINA?

Hi
I have a situation where I am to replace a legacy server which has multiple
clients and the communication is with a custom raw-byte format over TCP.
I was thinking that camel MINA must be perfect for the task and have written
a codec to encode and decode the messages.

However, the communication between the clients and server is mostly of type
"fire and forget", where the client do not wait for an answer but some
messages require a response. This means that neither the option sync=true
nor sync=false will suffice. The clients do not have the option to connect
to a certain port if an answer is required and another port if they require
no answer. Therefore I must implement a server which, based on the message
received, will return an answer or not return an answer.

My question is if this is possible using the camel MINA component?

I've made some experiments (JUnit tests) trying to change the
ExchangePattern in a route from a MINA endpoint with sync=true with
setExchangePattern(ExchangePattern.InOnly). By the looks of the printouts
from the minaLogger that doesn't do anything and the request message to the
endpoint is the same as the response to the client.

The silver bullet for me would be an option like "sync=messageDependent" and
in my implementation of ProtocolDecoder had the option to tell the MINA
component whether to keep the connection open for reply or not.

--
View this message in context: http://camel.465427.n5.nabble.com/Message-dependent-sync-with-MINA-tp5435721p5435721.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Message-dependent sync with MINA?

Posted by Claus Ibsen <cl...@gmail.com>.
On Fri, Jan 27, 2012 at 4:32 PM, andlu702 <an...@r2m.se> wrote:
> Hi
> I have a situation where I am to replace a legacy server which has multiple
> clients and the communication is with a custom raw-byte format over TCP.
> I was thinking that camel MINA must be perfect for the task and have written
> a codec to encode and decode the messages.
>
> However, the communication between the clients and server is mostly of type
> "fire and forget", where the client do not wait for an answer but some
> messages require a response. This means that neither the option sync=true
> nor sync=false will suffice. The clients do not have the option to connect
> to a certain port if an answer is required and another port if they require
> no answer. Therefore I must implement a server which, based on the message
> received, will return an answer or not return an answer.
>
> My question is if this is possible using the camel MINA component?
>
> I've made some experiments (JUnit tests) trying to change the
> ExchangePattern in a route from a MINA endpoint with sync=true with
> setExchangePattern(ExchangePattern.InOnly). By the looks of the printouts
> from the minaLogger that doesn't do anything and the request message to the
> endpoint is the same as the response to the client.
>
> The silver bullet for me would be an option like "sync=messageDependent" and
> in my implementation of ProtocolDecoder had the option to tell the MINA
> component whether to keep the connection open for reply or not.
>

You can set a header on the message to tell camel-mina whether to
disconnect the connection after use.
And I think if you set an empty/null body then it may detect this and
do not send back a reply. Check the source code.


> --
> View this message in context: http://camel.465427.n5.nabble.com/Message-dependent-sync-with-MINA-tp5435721p5435721.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/