You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@camel.apache.org by chadkelly <ch...@gmail.com> on 2015/12/11 02:06:49 UTC

Enable camel/netty4 to support full duplex (bidirectional) asynchronous sockets

Please, can any developers guide me on extending Camel/Netty4 to support full
duplex (bidirectional) asynchronous network communication over the exact
same UDP/TCP port? I need to accomplish this task before XMas with your
generosity and guidance. The target component is Netty4 for both UDP and
TCP. If you know of any existing solution that solves this problem, please
share, as this issue has much discussion with no published solution. The
requirements cannot change because existing systems (non-Camel) are already
designed to perform asynchronous bidirectional sockets I/O over the single
established socket (and session for TCP).

Relevant Camel tickets are already documented here:
https://issues.apache.org/jira/browse/CAMEL-1075
https://issues.apache.org/jira/browse/CAMEL-2624


Consider the following "invalid" example that attempts to enable a full
duplex asynchronous Camel route between endpoint1 and endpoint2. It
important to notice that this design will cause camel to open 1 tcp session
for “from route1 endpoint1” and 1 tcp session for “to route2 endpoint1”
(i.e. socket bind collision). This violates the one asynchronous
bidirectional socket requirement. 

<endpoint id="endpoint1"
uri="netty4:tcp://localhost:7000?sync=false&amp;disconnect=false..." />
<endpoint id="endpoint2"
uri="netty4:tcp://localhost:7001?sync=false&amp;disconnect=false..." />
<route id="route1">
	<from ref="endpoint1" />
	<to ref="endpoint2" /> 
</route>
<route id="route2">
	<from ref="endpoint2" />
	<to ref="endpoint1" /> 
</route>

What is the easiest design to enable this requirement? I prefer to use the
design of an existing Camel developer, because I am new to Camel. Two
initial design options are presented below:

Option1 is to add optional seda: or direct: component to the NettyConsumer
class (if such a thing can be done). For example, endpoint1 and endpoint2
have a seda: component to enable a producer backchannel. 
<endpoint id="endpoint1"
uri="netty4:tcp://localhost:7000?seda=mySeda1&amp;sync=false&amp;disconnect=false..."
/>
<endpoint id="endpoint2"
uri="netty4:tcp://localhost:7001?seda=mySeda2&amp;sync=false&amp;disconnect=false..."
/>
<route id="route1">
	<from ref="endpoint1" />
	<to uri="seda:mySeda2" /> 
</route>
<route id="route2">
	<from ref="endpoint2" />
	<to uri="seda:mySeda1" />
</route>

Option2 is to add optional localhost server to the NettyConsumer class (if
such a thing can be done). For example, endpoint1 and endpoint2 have a
localhostServerPort to enable a producer backchannel.

<endpoint id="endpoint1"
uri="netty4:tcp://localhost:7000?localhostServerPort=8000&amp;sync=false&amp;disconnect=false..."
/>
<endpoint id="endpoint2"
uri="netty4:tcp://localhost:7001?localhostServerPort=8001&amp;sync=false&amp;disconnect=false..."
/>
<route id="route1">
	<from ref="endpoint1" />
	<to
uri="netty4:tcp://localhost:8001?clientMode=true&amp;disconnect=false&amp;sync=false..."
/> 
</route>
<route id="route2">
	<from ref="endpoint2" />
	<to
uri="netty4:tcp://localhost:8000?clientMode=true&amp;disconnect=false&amp;sync=false..."
/>
</route>

Does this make sense? I may be typing things that may not make
implementation sense, so please guide me in coming up with any practical
solution that will work in Camel. 








--
View this message in context: http://camel.465427.n5.nabble.com/Enable-camel-netty4-to-support-full-duplex-bidirectional-asynchronous-sockets-tp5774972.html
Sent from the Camel Development mailing list archive at Nabble.com.

Re: Enable camel/netty4 to support full duplex (bidirectional) asynchronous sockets

Posted by Carl Nygard <cj...@gmail.com>.
Can you just write the Java bidirectional component as a standalone front end and let it talk to the two end points in camel?

--carl

> On Dec 10, 2015, at 8:06 PM, chadkelly <ch...@gmail.com> wrote:
> 
> Please, can any developers guide me on extending Camel/Netty4 to support full
> duplex (bidirectional) asynchronous network communication over the exact
> same UDP/TCP port? I need to accomplish this task before XMas with your
> generosity and guidance. The target component is Netty4 for both UDP and
> TCP. If you know of any existing solution that solves this problem, please
> share, as this issue has much discussion with no published solution. The
> requirements cannot change because existing systems (non-Camel) are already
> designed to perform asynchronous bidirectional sockets I/O over the single
> established socket (and session for TCP).
> 
> Relevant Camel tickets are already documented here:
> https://issues.apache.org/jira/browse/CAMEL-1075
> https://issues.apache.org/jira/browse/CAMEL-2624
> 
> 
> Consider the following "invalid" example that attempts to enable a full
> duplex asynchronous Camel route between endpoint1 and endpoint2. It
> important to notice that this design will cause camel to open 1 tcp session
> for “from route1 endpoint1” and 1 tcp session for “to route2 endpoint1”
> (i.e. socket bind collision). This violates the one asynchronous
> bidirectional socket requirement. 
> 
> <endpoint id="endpoint1"
> uri="netty4:tcp://localhost:7000?sync=false&amp;disconnect=false..." />
> <endpoint id="endpoint2"
> uri="netty4:tcp://localhost:7001?sync=false&amp;disconnect=false..." />
> <route id="route1">
>    <from ref="endpoint1" />
>    <to ref="endpoint2" /> 
> </route>
> <route id="route2">
>    <from ref="endpoint2" />
>    <to ref="endpoint1" /> 
> </route>
> 
> What is the easiest design to enable this requirement? I prefer to use the
> design of an existing Camel developer, because I am new to Camel. Two
> initial design options are presented below:
> 
> Option1 is to add optional seda: or direct: component to the NettyConsumer
> class (if such a thing can be done). For example, endpoint1 and endpoint2
> have a seda: component to enable a producer backchannel. 
> <endpoint id="endpoint1"
> uri="netty4:tcp://localhost:7000?seda=mySeda1&amp;sync=false&amp;disconnect=false..."
> />
> <endpoint id="endpoint2"
> uri="netty4:tcp://localhost:7001?seda=mySeda2&amp;sync=false&amp;disconnect=false..."
> />
> <route id="route1">
>    <from ref="endpoint1" />
>    <to uri="seda:mySeda2" /> 
> </route>
> <route id="route2">
>    <from ref="endpoint2" />
>    <to uri="seda:mySeda1" />
> </route>
> 
> Option2 is to add optional localhost server to the NettyConsumer class (if
> such a thing can be done). For example, endpoint1 and endpoint2 have a
> localhostServerPort to enable a producer backchannel.
> 
> <endpoint id="endpoint1"
> uri="netty4:tcp://localhost:7000?localhostServerPort=8000&amp;sync=false&amp;disconnect=false..."
> />
> <endpoint id="endpoint2"
> uri="netty4:tcp://localhost:7001?localhostServerPort=8001&amp;sync=false&amp;disconnect=false..."
> />
> <route id="route1">
>    <from ref="endpoint1" />
>    <to
> uri="netty4:tcp://localhost:8001?clientMode=true&amp;disconnect=false&amp;sync=false..."
> /> 
> </route>
> <route id="route2">
>    <from ref="endpoint2" />
>    <to
> uri="netty4:tcp://localhost:8000?clientMode=true&amp;disconnect=false&amp;sync=false..."
> />
> </route>
> 
> Does this make sense? I may be typing things that may not make
> implementation sense, so please guide me in coming up with any practical
> solution that will work in Camel. 
> 
> 
> 
> 
> 
> 
> 
> 
> --
> View this message in context: http://camel.465427.n5.nabble.com/Enable-camel-netty4-to-support-full-duplex-bidirectional-asynchronous-sockets-tp5774972.html
> Sent from the Camel Development mailing list archive at Nabble.com.