You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by huntc <hu...@mac.com> on 2009/01/05 08:24:51 UTC

Dependent endpoints

Hi there,

Happy New Year fellow camel riders.

I have a route something like this:


from(
 
"mina:tcp://127.0.0.1:8000?codec=zero3CodecFactory&amp;lazySessionCreation=true&amp;sync=true")
  .to(
   
"mina:tcp://127.0.0.1:8001?codec=zero3CodecFactory&amp;lazySessionCreation=true&amp;sync=true");


I was wondering it was somehow possible to have port 8000 closed if port
8001 closed and vice-versa? The above route works beautifully in that
traffic sent to port 8000 gets forwarded onto 8001 and vice-versa. However
what will happen is that the socket on port 8000 will close but the one on
8001 will stay up. 8001 is expecting the client connecting to 8000 to close.

In case you're wondering why I'm forwarding traffic on like this it is
because the thing that sits on 8001 is a horrid program that isn't reliable
from a networking perspective. I'm using MINA to front-end it so that I can
build in some decent network handling etc.

Any ideas?

Kind regards,
Christopher
-- 
View this message in context: http://www.nabble.com/Dependent-endpoints-tp21286657s22882p21286657.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Dependent endpoints

Posted by James Strachan <ja...@gmail.com>.
We certainly need to make it easier for any parts of a route (be it a
consumer, processor, bean or whatever) to be able to pause/resume,
start/stop existing routes.

2009/1/7 huntc <hu...@mac.com>:
>
> Hi James,
>
> Not quite the same use-case - it is perfectly valid for either of my tcp
> endpoints to close the connection. I was looking for a way to synchronise
> any closure with the other endpoint.
>
> I did start investigating this and saw that a MinaExchange was being passed
> downstream. From that I could close the upstream connection given that the
> MinaExchange allowed me to resolve the MINA IoSession. However I didn't get
> to the point where the upstream endpoint could see the downstream endpoint's
> IoSession... and then gave up because my customer decided that I should
> spend more time on this and re-write the Perl service using Camel. This now
> eliminates my original use-case.
>
> Thank you for replying.
>
> Kind regards,
> Christopher
> --
> View this message in context: http://www.nabble.com/Dependent-endpoints-tp21286657s22882p21341273.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



-- 
James
-------
http://macstrac.blogspot.com/

Open Source Integration
http://fusesource.com/

Re: Dependent endpoints

Posted by huntc <hu...@mac.com>.
Hi James,

Not quite the same use-case - it is perfectly valid for either of my tcp
endpoints to close the connection. I was looking for a way to synchronise
any closure with the other endpoint.

I did start investigating this and saw that a MinaExchange was being passed
downstream. From that I could close the upstream connection given that the
MinaExchange allowed me to resolve the MINA IoSession. However I didn't get
to the point where the upstream endpoint could see the downstream endpoint's
IoSession... and then gave up because my customer decided that I should
spend more time on this and re-write the Perl service using Camel. This now
eliminates my original use-case.

Thank you for replying.

Kind regards,
Christopher
-- 
View this message in context: http://www.nabble.com/Dependent-endpoints-tp21286657s22882p21341273.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Dependent endpoints

Posted by James Strachan <ja...@gmail.com>.
2009/1/5 huntc <hu...@mac.com>:
>
> Hi Claus,
>
> Thanks for your reply - as always very helpful.
>
> Following your advice I think I can share each endpoint's IOSession object
> (the MINA session). The decoder provides a finishDecode method when a
> session close occurs. Similarly there's a dispose method for the encoder
> which I presume is called on session closure (the docs don't actually say
> but I'll check).
>
> Given that an IOSession can technically change during the lifetime of my
> Camel endpoints, I'm going to have to find some way of communicating the
> object when sending from, say 8000 to 8001. Once that is solved each set of
> codec classes should then have the ability of closing down the other
> session.
>
> Perhaps the IOSession object should even be carried around in the exchange
> header...

If the mina endpoints could deal with reconnection for you - would
that solve your issue?

It sounds from this thread - that its gonna be possible to patch the
mina endpoint to do this
http://www.nabble.com/Tcp-component-in-client-mode-td21273871s22882.html

-- 
James
-------
http://macstrac.blogspot.com/

Open Source Integration
http://fusesource.com/

Re: Dependent endpoints

Posted by huntc <hu...@mac.com>.
Hi Claus,

Thanks for your reply - as always very helpful.

Following your advice I think I can share each endpoint's IOSession object
(the MINA session). The decoder provides a finishDecode method when a
session close occurs. Similarly there's a dispose method for the encoder
which I presume is called on session closure (the docs don't actually say
but I'll check).

Given that an IOSession can technically change during the lifetime of my
Camel endpoints, I'm going to have to find some way of communicating the
object when sending from, say 8000 to 8001. Once that is solved each set of
codec classes should then have the ability of closing down the other
session.

Perhaps the IOSession object should even be carried around in the exchange
header...

Tomorrow's challenge!

Kind regards,
Christopher
-- 
View this message in context: http://www.nabble.com/Dependent-endpoints-tp21286657s22882p21288973.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Dependent endpoints

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

On Mon, Jan 5, 2009 at 8:24 AM, huntc <hu...@mac.com> wrote:
>
> Hi there,
>
> Happy New Year fellow camel riders.
>
> I have a route something like this:
>
>
> from(
>
> "mina:tcp://127.0.0.1:8000?codec=zero3CodecFactory&amp;lazySessionCreation=true&amp;sync=true")
>  .to(
>
> "mina:tcp://127.0.0.1:8001?codec=zero3CodecFactory&amp;lazySessionCreation=true&amp;sync=true");
>
>
> I was wondering it was somehow possible to have port 8000 closed if port
> 8001 closed and vice-versa? The above route works beautifully in that
> traffic sent to port 8000 gets forwarded onto 8001 and vice-versa. However
> what will happen is that the socket on port 8000 will close but the one on
> 8001 will stay up. 8001 is expecting the client connecting to 8000 to close.
>
> In case you're wondering why I'm forwarding traffic on like this it is
> because the thing that sits on 8001 is a horrid program that isn't reliable
> from a networking perspective. I'm using MINA to front-end it so that I can
> build in some decent network handling etc.
>
> Any ideas?
Nice use-case. I am just speculating. In Mina you have a session
object and I think there are some callbacks for session closed or
exception thrown etc. I guess if you could get a hook in the event
when the socket on port 8000 is closed. If so you can then instruct
8001 to close as well (somehow).

Maybe the MINA API has some hints there. I can see you are using your
own codec. Maybe you have the callbacks there you can leverage.


>
> Kind regards,
> Christopher
> --
> View this message in context: http://www.nabble.com/Dependent-endpoints-tp21286657s22882p21286657.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 

/Claus Ibsen
Apache Camel Committer
Blog: http://davsclaus.blogspot.com/