You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Sachin <sa...@gmail.com> on 2011/06/03 14:16:19 UTC

Camel with Netty, strange requirement

Hi ,

I am using Camel 2.6 with netty 3.2.3 version. My netty producer and
consumer are working fine and i am able to process request and response
using Object en/decoder.
But i have a strange requirement. An other client, which is writing request
on port, is not using camel or netty, it's a simple plain java client.
Client doesnt have netty producer and exchange refernce. Even though i am
able to receive request and my Processor is being called using line
delimeter decoder and encoder.
But while sending response back, i need socket object refernce, so that i
can write on outputstream of that socket, as my client cant read from
exchange, neither they can use any decoder.
Is there any way, i get access to socket object in processor class from
exchange object? Please guide me.

Regards
Sachin

--
View this message in context: http://camel.465427.n5.nabble.com/Camel-with-Netty-strange-requirement-tp4450979p4450979.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel with Netty, strange requirement

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

And check the source code of camel-netty. Maybe you can spot an
improvement to fit your need.
But I think the answer is in the Netty community/documentation.


On Mon, Jun 6, 2011 at 8:09 AM, Claus Ibsen <cl...@gmail.com> wrote:
> On Mon, Jun 6, 2011 at 8:03 AM, Sachin <sa...@gmail.com> wrote:
>> Thanks for your response,it's great to hear from Ibsen directly :) .
>> I am already doing it as below.
>>
>> SocketAddress remoteAddress
>> =exchange.getIn().getHeader(NettyConstants.NETTY_REMOTE_ADDRESS,
>> SocketAddress.class);
>> ChannelHandlerContext  channelHandlerContext =(ChannelHandlerContext)
>> exchange.getIn().getHeader(NettyConstants.NETTY_CHANNEL_HANDLER_CONTEXT);
>> SocketAddress localAddress =
>> (SocketAddress)channelHandlerContext.getChannel().getLocalAddress();
>>
>> But by this , i am only getting local and remote address, and to get socket
>> object , i need to create a new socket object , which doesnt fulfill my
>> scenario.
>>
>> I have to get same socket object, so that i can write my response back.
>> Please guide me.
>>
>
> Thats the stuff that Netty exposes to Camel. I suggest you ask/check
> the Netty community/documentation for any pointers.
>
>
>> Regards
>> Sachin
>>
>> --
>> View this message in context: http://camel.465427.n5.nabble.com/Camel-with-Netty-strange-requirement-tp4450979p4457745.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/
>



-- 
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/

Re: Camel with Netty, strange requirement

Posted by Claus Ibsen <cl...@gmail.com>.
On Mon, Jun 6, 2011 at 8:03 AM, Sachin <sa...@gmail.com> wrote:
> Thanks for your response,it's great to hear from Ibsen directly :) .
> I am already doing it as below.
>
> SocketAddress remoteAddress
> =exchange.getIn().getHeader(NettyConstants.NETTY_REMOTE_ADDRESS,
> SocketAddress.class);
> ChannelHandlerContext  channelHandlerContext =(ChannelHandlerContext)
> exchange.getIn().getHeader(NettyConstants.NETTY_CHANNEL_HANDLER_CONTEXT);
> SocketAddress localAddress =
> (SocketAddress)channelHandlerContext.getChannel().getLocalAddress();
>
> But by this , i am only getting local and remote address, and to get socket
> object , i need to create a new socket object , which doesnt fulfill my
> scenario.
>
> I have to get same socket object, so that i can write my response back.
> Please guide me.
>

Thats the stuff that Netty exposes to Camel. I suggest you ask/check
the Netty community/documentation for any pointers.


> Regards
> Sachin
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Camel-with-Netty-strange-requirement-tp4450979p4457745.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/

Re: Camel with Netty, strange requirement

Posted by Sachin <sa...@gmail.com>.
Thanks for your response,it's great to hear from Ibsen directly :) .
I am already doing it as below.

SocketAddress remoteAddress
=exchange.getIn().getHeader(NettyConstants.NETTY_REMOTE_ADDRESS,
SocketAddress.class);
ChannelHandlerContext  channelHandlerContext =(ChannelHandlerContext)
exchange.getIn().getHeader(NettyConstants.NETTY_CHANNEL_HANDLER_CONTEXT);
SocketAddress localAddress =
(SocketAddress)channelHandlerContext.getChannel().getLocalAddress();

But by this , i am only getting local and remote address, and to get socket
object , i need to create a new socket object , which doesnt fulfill my
scenario.

I have to get same socket object, so that i can write my response back.
Please guide me.

Regards
Sachin

--
View this message in context: http://camel.465427.n5.nabble.com/Camel-with-Netty-strange-requirement-tp4450979p4457745.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel with Netty, strange requirement

Posted by Claus Ibsen <cl...@gmail.com>.
You can get access to Netty context from a header on the message.

When the Exchange is created in camel-netty it sets as follows:

ChannelHandlerContext ctx
exchange.getIn().setHeader(NettyConstants.NETTY_CHANNEL_HANDLER_CONTEXT, ctx);



On Fri, Jun 3, 2011 at 2:16 PM, Sachin <sa...@gmail.com> wrote:
> Hi ,
>
> I am using Camel 2.6 with netty 3.2.3 version. My netty producer and
> consumer are working fine and i am able to process request and response
> using Object en/decoder.
> But i have a strange requirement. An other client, which is writing request
> on port, is not using camel or netty, it's a simple plain java client.
> Client doesnt have netty producer and exchange refernce. Even though i am
> able to receive request and my Processor is being called using line
> delimeter decoder and encoder.
> But while sending response back, i need socket object refernce, so that i
> can write on outputstream of that socket, as my client cant read from
> exchange, neither they can use any decoder.
> Is there any way, i get access to socket object in processor class from
> exchange object? Please guide me.
>
> Regards
> Sachin
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Camel-with-Netty-strange-requirement-tp4450979p4450979.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/