You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Alexander Kaiser <al...@gmail.com> on 2012/06/18 15:05:55 UTC

Single request with multiple replies over TCP

Hi,

I am trying to connect to a server with mina. The server sends a hello
message on socket connect, then I send it a command and want to receive the
servers reply in the message body.

camel-mina connects server
                  <-- welcome message
command -->
                  <-- reply

Basically I need to skip, or parse and skip the welcome message, and then
decode the reply.

With mina I can get only the servers welcome message. I read in a
thread<http://camel.465427.n5.nabble.com/Single-request-with-multiple-replies-over-TCP-td5022206.html>on
this subject that mina2 supports this kind of scenario, but I can't
find
any documentation on mina2.

Does mina2 indeed support this?

Many thanks,
Alexander

Re: Single request with multiple replies over TCP

Posted by Claus Ibsen <cl...@gmail.com>.
On Wed, Jun 20, 2012 at 10:21 PM, Alexander Kaiser
<al...@gmail.com> wrote:
> Hi Claus,
>
> thanks for your reply! The protocol is indeed line based. I actually tried
> to write my own codec, but without success, the decode method always was
> called two times, and only the result of the first call ended up in the
> message body. That's why I was asking for mina2 docu.
>

Oh I think your use-case has been covered before, and that Mina /
Mina2 can do this with a custom codec and/or filter.

I think it offers a filtering approach so you ought to be able to
filter the welcome message, and prevent it from going
forward to the other codec / filters. And this only trigger your codec
/ textline codec to fire once.

I suggest to ask this / read the mina docs / search the mina community
about this use-case.
And maybe also try look at stackoverflow as someone else must have
found a solution for this.

> Anyway, I ended up writing my own component, which also gives me a very
> nice concise URI, so I am happy with that. But of course now I had to
> implement some low level socket communication which I had wanted to avoid
> initially.
>

Well you can use mina for that.

> Alexander
>
> 2012/6/19 Claus Ibsen <cl...@gmail.com>
>
>> On Mon, Jun 18, 2012 at 3:05 PM, Alexander Kaiser
>> <al...@gmail.com> wrote:
>> > Hi,
>> >
>> > I am trying to connect to a server with mina. The server sends a hello
>> > message on socket connect, then I send it a command and want to receive
>> the
>> > servers reply in the message body.
>> >
>> > camel-mina connects server
>> >                  <-- welcome message
>> > command -->
>> >                  <-- reply
>> >
>> > Basically I need to skip, or parse and skip the welcome message, and then
>> > decode the reply.
>> >
>> > With mina I can get only the servers welcome message. I read in a
>> > thread<
>> http://camel.465427.n5.nabble.com/Single-request-with-multiple-replies-over-TCP-td5022206.html
>> >on
>> > this subject that mina2 supports this kind of scenario, but I can't
>> > find
>> > any documentation on mina2.
>> >
>> > Does mina2 indeed support this?
>> >
>> > Many thanks,
>> > Alexander
>>
>> What protocol are you using?
>> A text based, with a line terminator or something?
>>
>> You could possible build a custom codec, that understands the welcome
>> message, and is capable of skipping that.
>>
>>
>>
>>
>> --
>> Claus Ibsen
>> -----------------
>> FuseSource
>> Email: cibsen@fusesource.com
>> Web: http://fusesource.com
>> Twitter: davsclaus, fusenews
>> Blog: http://davsclaus.com
>> Author of Camel in Action: http://www.manning.com/ibsen
>>
>
>
>
> --
> Alexander



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

Re: Single request with multiple replies over TCP

Posted by Alexander Kaiser <al...@gmail.com>.
Hi Claus,

thanks for your reply! The protocol is indeed line based. I actually tried
to write my own codec, but without success, the decode method always was
called two times, and only the result of the first call ended up in the
message body. That's why I was asking for mina2 docu.

Anyway, I ended up writing my own component, which also gives me a very
nice concise URI, so I am happy with that. But of course now I had to
implement some low level socket communication which I had wanted to avoid
initially.

Alexander

2012/6/19 Claus Ibsen <cl...@gmail.com>

> On Mon, Jun 18, 2012 at 3:05 PM, Alexander Kaiser
> <al...@gmail.com> wrote:
> > Hi,
> >
> > I am trying to connect to a server with mina. The server sends a hello
> > message on socket connect, then I send it a command and want to receive
> the
> > servers reply in the message body.
> >
> > camel-mina connects server
> >                  <-- welcome message
> > command -->
> >                  <-- reply
> >
> > Basically I need to skip, or parse and skip the welcome message, and then
> > decode the reply.
> >
> > With mina I can get only the servers welcome message. I read in a
> > thread<
> http://camel.465427.n5.nabble.com/Single-request-with-multiple-replies-over-TCP-td5022206.html
> >on
> > this subject that mina2 supports this kind of scenario, but I can't
> > find
> > any documentation on mina2.
> >
> > Does mina2 indeed support this?
> >
> > Many thanks,
> > Alexander
>
> What protocol are you using?
> A text based, with a line terminator or something?
>
> You could possible build a custom codec, that understands the welcome
> message, and is capable of skipping that.
>
>
>
>
> --
> Claus Ibsen
> -----------------
> FuseSource
> Email: cibsen@fusesource.com
> Web: http://fusesource.com
> Twitter: davsclaus, fusenews
> Blog: http://davsclaus.com
> Author of Camel in Action: http://www.manning.com/ibsen
>



-- 
Alexander

Re: Single request with multiple replies over TCP

Posted by Claus Ibsen <cl...@gmail.com>.
On Mon, Jun 18, 2012 at 3:05 PM, Alexander Kaiser
<al...@gmail.com> wrote:
> Hi,
>
> I am trying to connect to a server with mina. The server sends a hello
> message on socket connect, then I send it a command and want to receive the
> servers reply in the message body.
>
> camel-mina connects server
>                  <-- welcome message
> command -->
>                  <-- reply
>
> Basically I need to skip, or parse and skip the welcome message, and then
> decode the reply.
>
> With mina I can get only the servers welcome message. I read in a
> thread<http://camel.465427.n5.nabble.com/Single-request-with-multiple-replies-over-TCP-td5022206.html>on
> this subject that mina2 supports this kind of scenario, but I can't
> find
> any documentation on mina2.
>
> Does mina2 indeed support this?
>
> Many thanks,
> Alexander

What protocol are you using?
A text based, with a line terminator or something?

You could possible build a custom codec, that understands the welcome
message, and is capable of skipping that.




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