You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Sadanand Kusma <sk...@ARCCorp.com> on 2010/08/18 19:53:39 UTC

netty issue

I am actually trying out asynchronous messaging with Netty producer. I get below exception even though sync =false. Also, Is this  the right way to implement asynchronous processing.
Here is my route:
            from("netty:tcp://localhost:6205?textline=true&sync=true").process(new Processor() {
                int i=0;
                  public void process(Exchange exchange) throws Exception {
                    String body = exchange.getIn().getBody(String.class);
                        Thread.sleep(2000);
                    exchange.getOut().setBody("Bye 1" + body);
                }
            });

            from("file:///test/test/response")
            .convertBodyTo(String.class)
            .threads(1)
            .to("netty:tcp://localhost:6205?textline=true&sync=false")
            .to("log:+++ reply++++");


org.apache.camel.ExchangeTimedOutException: The OUT message was not received within: 30000 millis. Exchange[GenericFileMessage with body: Bye 1hello2]
      at org.apache.camel.component.netty.handlers.ClientChannelHandler.exceptionCaught(ClientChannelHandler.java:79)
      at org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:122)
      at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:545)
      at org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:754)
      at org.jboss.netty.handler.codec.oneone.OneToOneDecoder.handleUpstream(OneToOneDecoder.java:66)
      at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:545)
      at org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:754)
      at org.jboss.netty.handler.codec.frame.FrameDecoder.exceptionCaught(FrameDecoder.java:238)
      at org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:122)
      at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:545)
      at org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:754)
      at org.jboss.netty.channel.Channels.fireExceptionCaught(Channels.java:443)
      at org.jboss.netty.handler.timeout.ReadTimeoutHandler.readTimedOut(ReadTimeoutHandler.java:210)
      at org.jboss.netty.handler.timeout.ReadTimeoutHandler$ReadTimeoutTask.run(ReadTimeoutHandler.java:237)
      at org.jboss.netty.util.HashedWheelTimer$HashedWheelTimeout.expire(HashedWheelTimer.java:504)
      at org.jboss.netty.util.HashedWheelTimer$Worker.notifyExpiredTimeouts(HashedWheelTimer.java:419)
      at org.jboss.netty.util.HashedWheelTimer$Worker.run(HashedWheelTimer.java:369)
      at org.jboss.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnable.java:108)
      at java.lang.Thread.run(Thread.java:595)


netty timeout bug.

Posted by Sadanand Kusma <sk...@ARCCorp.com>.
Camel netty bug created. https://issues.apache.org/activemq/browse/CAMEL-3081


RE: netty issue

Posted by Sadanand Kusma <sk...@ARCCorp.com>.
1. That is good. Is it always going to run in async mode, is there any option to make it run in sync mode. Also with threads(1), I can make sure only one TCP connection and stream messages one after the other sequentially and receive messages asynchronously?. 

2.		from("netty:tcp://localhost:6205?textline=true&sync=true").process(new Processor() {
		    int i=0;
			public void process(Exchange exchange) throws Exception {
		        String body = exchange.getIn().getBody(String.class);
				Thread.sleep(2000);
		        exchange.getOut().setBody("Bye 1" + body);
		       // if(i++%2==1) throw new IOException("custom exception");
		    }
		});
TCP server replied and producer got response. I guess it may be a defect in the netty producer. 

-----Original Message-----
From: Claus Ibsen [mailto:claus.ibsen@gmail.com] 
Sent: Sunday, August 22, 2010 9:02 AM
To: users@camel.apache.org
Subject: Re: netty issue

On Thu, Aug 19, 2010 at 11:20 PM, Sadanand Kusma <sk...@arccorp.com> wrote:
> As suggested, I tried this with exchange pattern as inout. I think there are 2 issues.
> 1. it is not continuing with reply immediately, it waits till it receives a response. is this how it supposed to work in async mode?.

No it doesn't wait in that sense there is no thread blocked. When the
reply comes back the async routing engine will continue in the Camel
route, and therefore in your example go to the log:reply endpoint.
That may be why you "think" it waits.



I would think that like we had in deprecated toasync feature, it sends
the async response to a new route to process messages received
asynchronously.
>                from("file:///test/test/response")
>                .convertBodyTo(String.class)
>                .threads(1)
>                .to(ExchangePattern.InOut,"netty:tcp://localhost:6205?textline=true&sync=true")
>                .to("log:+++ reply++++");
> 2. it throws this exception even though it receives the response. Detailed stack trace is in the first post.
> 2010-08-19 16:40:38,663 [         Hashed wheel timer #1] DefaultErrorHandler            DEBUG Failed delivery for exchangeId: afa68733-6228-4da2-b831-5a56ee39db51. On delivery attempt: 0 caught: org.apache.camel.ExchangeTimedOutException: The OUT message was not received within: 30000 millis. Exchange[GenericFileMessage with body: Bye 1hello1]
>

The TCP server did not reply within the 30 seconds default timeout. So
check the TCP server what is happening.


>
> -----Original Message-----
> From: Claus Ibsen [mailto:claus.ibsen@gmail.com]
> Sent: Thursday, August 19, 2010 11:06 AM
> To: users@camel.apache.org
> Subject: Re: netty issue
>
> On Thu, Aug 19, 2010 at 4:45 PM, Sadanand Kusma <sk...@arccorp.com> wrote:
>> Thanks for the response, if you set sync=true doesn't it make a synchronous call.
>> Are you saying that it always runs in a async mode?,how do we tell it to run in an async mode?.
>>
>
> Well the sync option is badly named, now the async non blocking
> routing engine is in place.
> Its kinda still there for compatibility. So view the sync as
> request/reply (InOut)
>
> What you need to ensure is the MEP is InOut. And sync=true is like saying InOut.
> The async routing ensures the thread is not blocked while waiting for
> the reply to come back from the TCP server.
>
> We should maybe @deprecate sync option and let it check the MEP of the Exchange.
>
>
>> -----Original Message-----
>> From: Willem Jiang [mailto:willem.jiang@gmail.com]
>> Sent: Wednesday, August 18, 2010 10:43 PM
>> To: users@camel.apache.org
>> Subject: Re: netty issue
>>
>> I just checked the netty's doc and camel-netty producer's code, if you
>> set the sync=false, the producer will never expect the response, and the
>>  async callback will never be called.
>>
>> So you just need to change your route like this
>>
>>  from("file:///test/test/response")
>>              .convertBodyTo(String.class)
>>              .threads(1)
>>              .to("netty:tcp://localhost:6205?textline=true&sync=true")
>>              .to("log:+++ reply++++");
>>
>>
>> Willem
>>
>> Sadanand Kusma wrote:
>>> I am actually trying out asynchronous messaging with Netty producer. I get below exception even though sync =false. Also, Is this  the right way to implement asynchronous processing.
>>> Here is my route:
>>>             from("netty:tcp://localhost:6205?textline=true&sync=true").process(new Processor() {
>>>                 int i=0;
>>>                   public void process(Exchange exchange) throws Exception {
>>>                     String body = exchange.getIn().getBody(String.class);
>>>                         Thread.sleep(2000);
>>>                     exchange.getOut().setBody("Bye 1" + body);
>>>                 }
>>>             });
>>>
>>>             from("file:///test/test/response")
>>>             .convertBodyTo(String.class)
>>>             .threads(1)
>>>             .to("netty:tcp://localhost:6205?textline=true&sync=false")
>>>             .to("log:+++ reply++++");
>>>
>>>
>>> org.apache.camel.ExchangeTimedOutException: The OUT message was not received within: 30000 millis. Exchange[GenericFileMessage with body: Bye 1hello2]
>>>       at org.apache.camel.component.netty.handlers.ClientChannelHandler.exceptionCaught(ClientChannelHandler.java:79)
>>>       at org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:122)
>>>       at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:545)
>>>       at org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:754)
>>>       at org.jboss.netty.handler.codec.oneone.OneToOneDecoder.handleUpstream(OneToOneDecoder.java:66)
>>>       at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:545)
>>>       at org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:754)
>>>       at org.jboss.netty.handler.codec.frame.FrameDecoder.exceptionCaught(FrameDecoder.java:238)
>>>       at org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:122)
>>>       at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:545)
>>>       at org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:754)
>>>       at org.jboss.netty.channel.Channels.fireExceptionCaught(Channels.java:443)
>>>       at org.jboss.netty.handler.timeout.ReadTimeoutHandler.readTimedOut(ReadTimeoutHandler.java:210)
>>>       at org.jboss.netty.handler.timeout.ReadTimeoutHandler$ReadTimeoutTask.run(ReadTimeoutHandler.java:237)
>>>       at org.jboss.netty.util.HashedWheelTimer$HashedWheelTimeout.expire(HashedWheelTimer.java:504)
>>>       at org.jboss.netty.util.HashedWheelTimer$Worker.notifyExpiredTimeouts(HashedWheelTimer.java:419)
>>>       at org.jboss.netty.util.HashedWheelTimer$Worker.run(HashedWheelTimer.java:369)
>>>       at org.jboss.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnable.java:108)
>>>       at java.lang.Thread.run(Thread.java:595)
>>>
>>>
>>
>>
>
>
>
> --
> Claus Ibsen
> Apache Camel Committer
>
> Author of Camel in Action: http://www.manning.com/ibsen/
> Open Source Integration: http://fusesource.com
> Blog: http://davsclaus.blogspot.com/
> Twitter: http://twitter.com/davsclaus
>



-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Re: netty issue

Posted by Claus Ibsen <cl...@gmail.com>.
On Thu, Aug 19, 2010 at 11:20 PM, Sadanand Kusma <sk...@arccorp.com> wrote:
> As suggested, I tried this with exchange pattern as inout. I think there are 2 issues.
> 1. it is not continuing with reply immediately, it waits till it receives a response. is this how it supposed to work in async mode?.

No it doesn't wait in that sense there is no thread blocked. When the
reply comes back the async routing engine will continue in the Camel
route, and therefore in your example go to the log:reply endpoint.
That may be why you "think" it waits.



I would think that like we had in deprecated toasync feature, it sends
the async response to a new route to process messages received
asynchronously.
>                from("file:///test/test/response")
>                .convertBodyTo(String.class)
>                .threads(1)
>                .to(ExchangePattern.InOut,"netty:tcp://localhost:6205?textline=true&sync=true")
>                .to("log:+++ reply++++");
> 2. it throws this exception even though it receives the response. Detailed stack trace is in the first post.
> 2010-08-19 16:40:38,663 [         Hashed wheel timer #1] DefaultErrorHandler            DEBUG Failed delivery for exchangeId: afa68733-6228-4da2-b831-5a56ee39db51. On delivery attempt: 0 caught: org.apache.camel.ExchangeTimedOutException: The OUT message was not received within: 30000 millis. Exchange[GenericFileMessage with body: Bye 1hello1]
>

The TCP server did not reply within the 30 seconds default timeout. So
check the TCP server what is happening.


>
> -----Original Message-----
> From: Claus Ibsen [mailto:claus.ibsen@gmail.com]
> Sent: Thursday, August 19, 2010 11:06 AM
> To: users@camel.apache.org
> Subject: Re: netty issue
>
> On Thu, Aug 19, 2010 at 4:45 PM, Sadanand Kusma <sk...@arccorp.com> wrote:
>> Thanks for the response, if you set sync=true doesn't it make a synchronous call.
>> Are you saying that it always runs in a async mode?,how do we tell it to run in an async mode?.
>>
>
> Well the sync option is badly named, now the async non blocking
> routing engine is in place.
> Its kinda still there for compatibility. So view the sync as
> request/reply (InOut)
>
> What you need to ensure is the MEP is InOut. And sync=true is like saying InOut.
> The async routing ensures the thread is not blocked while waiting for
> the reply to come back from the TCP server.
>
> We should maybe @deprecate sync option and let it check the MEP of the Exchange.
>
>
>> -----Original Message-----
>> From: Willem Jiang [mailto:willem.jiang@gmail.com]
>> Sent: Wednesday, August 18, 2010 10:43 PM
>> To: users@camel.apache.org
>> Subject: Re: netty issue
>>
>> I just checked the netty's doc and camel-netty producer's code, if you
>> set the sync=false, the producer will never expect the response, and the
>>  async callback will never be called.
>>
>> So you just need to change your route like this
>>
>>  from("file:///test/test/response")
>>              .convertBodyTo(String.class)
>>              .threads(1)
>>              .to("netty:tcp://localhost:6205?textline=true&sync=true")
>>              .to("log:+++ reply++++");
>>
>>
>> Willem
>>
>> Sadanand Kusma wrote:
>>> I am actually trying out asynchronous messaging with Netty producer. I get below exception even though sync =false. Also, Is this  the right way to implement asynchronous processing.
>>> Here is my route:
>>>             from("netty:tcp://localhost:6205?textline=true&sync=true").process(new Processor() {
>>>                 int i=0;
>>>                   public void process(Exchange exchange) throws Exception {
>>>                     String body = exchange.getIn().getBody(String.class);
>>>                         Thread.sleep(2000);
>>>                     exchange.getOut().setBody("Bye 1" + body);
>>>                 }
>>>             });
>>>
>>>             from("file:///test/test/response")
>>>             .convertBodyTo(String.class)
>>>             .threads(1)
>>>             .to("netty:tcp://localhost:6205?textline=true&sync=false")
>>>             .to("log:+++ reply++++");
>>>
>>>
>>> org.apache.camel.ExchangeTimedOutException: The OUT message was not received within: 30000 millis. Exchange[GenericFileMessage with body: Bye 1hello2]
>>>       at org.apache.camel.component.netty.handlers.ClientChannelHandler.exceptionCaught(ClientChannelHandler.java:79)
>>>       at org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:122)
>>>       at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:545)
>>>       at org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:754)
>>>       at org.jboss.netty.handler.codec.oneone.OneToOneDecoder.handleUpstream(OneToOneDecoder.java:66)
>>>       at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:545)
>>>       at org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:754)
>>>       at org.jboss.netty.handler.codec.frame.FrameDecoder.exceptionCaught(FrameDecoder.java:238)
>>>       at org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:122)
>>>       at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:545)
>>>       at org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:754)
>>>       at org.jboss.netty.channel.Channels.fireExceptionCaught(Channels.java:443)
>>>       at org.jboss.netty.handler.timeout.ReadTimeoutHandler.readTimedOut(ReadTimeoutHandler.java:210)
>>>       at org.jboss.netty.handler.timeout.ReadTimeoutHandler$ReadTimeoutTask.run(ReadTimeoutHandler.java:237)
>>>       at org.jboss.netty.util.HashedWheelTimer$HashedWheelTimeout.expire(HashedWheelTimer.java:504)
>>>       at org.jboss.netty.util.HashedWheelTimer$Worker.notifyExpiredTimeouts(HashedWheelTimer.java:419)
>>>       at org.jboss.netty.util.HashedWheelTimer$Worker.run(HashedWheelTimer.java:369)
>>>       at org.jboss.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnable.java:108)
>>>       at java.lang.Thread.run(Thread.java:595)
>>>
>>>
>>
>>
>
>
>
> --
> Claus Ibsen
> Apache Camel Committer
>
> Author of Camel in Action: http://www.manning.com/ibsen/
> Open Source Integration: http://fusesource.com
> Blog: http://davsclaus.blogspot.com/
> Twitter: http://twitter.com/davsclaus
>



-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

RE: netty issue

Posted by Sadanand Kusma <sk...@ARCCorp.com>.
As suggested, I tried this with exchange pattern as inout. I think there are 2 issues.
1. it is not continuing with reply immediately, it waits till it receives a response. is this how it supposed to work in async mode?.I would think that like we had in deprecated toasync feature, it sends the async response to a new route to process messages received asynchronously.
		from("file:///test/test/response")
		.convertBodyTo(String.class)
		.threads(1)
		.to(ExchangePattern.InOut,"netty:tcp://localhost:6205?textline=true&sync=true")
		.to("log:+++ reply++++");
2. it throws this exception even though it receives the response. Detailed stack trace is in the first post.
2010-08-19 16:40:38,663 [         Hashed wheel timer #1] DefaultErrorHandler            DEBUG Failed delivery for exchangeId: afa68733-6228-4da2-b831-5a56ee39db51. On delivery attempt: 0 caught: org.apache.camel.ExchangeTimedOutException: The OUT message was not received within: 30000 millis. Exchange[GenericFileMessage with body: Bye 1hello1]


-----Original Message-----
From: Claus Ibsen [mailto:claus.ibsen@gmail.com] 
Sent: Thursday, August 19, 2010 11:06 AM
To: users@camel.apache.org
Subject: Re: netty issue

On Thu, Aug 19, 2010 at 4:45 PM, Sadanand Kusma <sk...@arccorp.com> wrote:
> Thanks for the response, if you set sync=true doesn't it make a synchronous call.
> Are you saying that it always runs in a async mode?,how do we tell it to run in an async mode?.
>

Well the sync option is badly named, now the async non blocking
routing engine is in place.
Its kinda still there for compatibility. So view the sync as
request/reply (InOut)

What you need to ensure is the MEP is InOut. And sync=true is like saying InOut.
The async routing ensures the thread is not blocked while waiting for
the reply to come back from the TCP server.

We should maybe @deprecate sync option and let it check the MEP of the Exchange.


> -----Original Message-----
> From: Willem Jiang [mailto:willem.jiang@gmail.com]
> Sent: Wednesday, August 18, 2010 10:43 PM
> To: users@camel.apache.org
> Subject: Re: netty issue
>
> I just checked the netty's doc and camel-netty producer's code, if you
> set the sync=false, the producer will never expect the response, and the
>  async callback will never be called.
>
> So you just need to change your route like this
>
>  from("file:///test/test/response")
>              .convertBodyTo(String.class)
>              .threads(1)
>              .to("netty:tcp://localhost:6205?textline=true&sync=true")
>              .to("log:+++ reply++++");
>
>
> Willem
>
> Sadanand Kusma wrote:
>> I am actually trying out asynchronous messaging with Netty producer. I get below exception even though sync =false. Also, Is this  the right way to implement asynchronous processing.
>> Here is my route:
>>             from("netty:tcp://localhost:6205?textline=true&sync=true").process(new Processor() {
>>                 int i=0;
>>                   public void process(Exchange exchange) throws Exception {
>>                     String body = exchange.getIn().getBody(String.class);
>>                         Thread.sleep(2000);
>>                     exchange.getOut().setBody("Bye 1" + body);
>>                 }
>>             });
>>
>>             from("file:///test/test/response")
>>             .convertBodyTo(String.class)
>>             .threads(1)
>>             .to("netty:tcp://localhost:6205?textline=true&sync=false")
>>             .to("log:+++ reply++++");
>>
>>
>> org.apache.camel.ExchangeTimedOutException: The OUT message was not received within: 30000 millis. Exchange[GenericFileMessage with body: Bye 1hello2]
>>       at org.apache.camel.component.netty.handlers.ClientChannelHandler.exceptionCaught(ClientChannelHandler.java:79)
>>       at org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:122)
>>       at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:545)
>>       at org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:754)
>>       at org.jboss.netty.handler.codec.oneone.OneToOneDecoder.handleUpstream(OneToOneDecoder.java:66)
>>       at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:545)
>>       at org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:754)
>>       at org.jboss.netty.handler.codec.frame.FrameDecoder.exceptionCaught(FrameDecoder.java:238)
>>       at org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:122)
>>       at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:545)
>>       at org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:754)
>>       at org.jboss.netty.channel.Channels.fireExceptionCaught(Channels.java:443)
>>       at org.jboss.netty.handler.timeout.ReadTimeoutHandler.readTimedOut(ReadTimeoutHandler.java:210)
>>       at org.jboss.netty.handler.timeout.ReadTimeoutHandler$ReadTimeoutTask.run(ReadTimeoutHandler.java:237)
>>       at org.jboss.netty.util.HashedWheelTimer$HashedWheelTimeout.expire(HashedWheelTimer.java:504)
>>       at org.jboss.netty.util.HashedWheelTimer$Worker.notifyExpiredTimeouts(HashedWheelTimer.java:419)
>>       at org.jboss.netty.util.HashedWheelTimer$Worker.run(HashedWheelTimer.java:369)
>>       at org.jboss.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnable.java:108)
>>       at java.lang.Thread.run(Thread.java:595)
>>
>>
>
>



-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Re: netty issue

Posted by Claus Ibsen <cl...@gmail.com>.
On Thu, Aug 19, 2010 at 4:45 PM, Sadanand Kusma <sk...@arccorp.com> wrote:
> Thanks for the response, if you set sync=true doesn't it make a synchronous call.
> Are you saying that it always runs in a async mode?,how do we tell it to run in an async mode?.
>

Well the sync option is badly named, now the async non blocking
routing engine is in place.
Its kinda still there for compatibility. So view the sync as
request/reply (InOut)

What you need to ensure is the MEP is InOut. And sync=true is like saying InOut.
The async routing ensures the thread is not blocked while waiting for
the reply to come back from the TCP server.

We should maybe @deprecate sync option and let it check the MEP of the Exchange.


> -----Original Message-----
> From: Willem Jiang [mailto:willem.jiang@gmail.com]
> Sent: Wednesday, August 18, 2010 10:43 PM
> To: users@camel.apache.org
> Subject: Re: netty issue
>
> I just checked the netty's doc and camel-netty producer's code, if you
> set the sync=false, the producer will never expect the response, and the
>  async callback will never be called.
>
> So you just need to change your route like this
>
>  from("file:///test/test/response")
>              .convertBodyTo(String.class)
>              .threads(1)
>              .to("netty:tcp://localhost:6205?textline=true&sync=true")
>              .to("log:+++ reply++++");
>
>
> Willem
>
> Sadanand Kusma wrote:
>> I am actually trying out asynchronous messaging with Netty producer. I get below exception even though sync =false. Also, Is this  the right way to implement asynchronous processing.
>> Here is my route:
>>             from("netty:tcp://localhost:6205?textline=true&sync=true").process(new Processor() {
>>                 int i=0;
>>                   public void process(Exchange exchange) throws Exception {
>>                     String body = exchange.getIn().getBody(String.class);
>>                         Thread.sleep(2000);
>>                     exchange.getOut().setBody("Bye 1" + body);
>>                 }
>>             });
>>
>>             from("file:///test/test/response")
>>             .convertBodyTo(String.class)
>>             .threads(1)
>>             .to("netty:tcp://localhost:6205?textline=true&sync=false")
>>             .to("log:+++ reply++++");
>>
>>
>> org.apache.camel.ExchangeTimedOutException: The OUT message was not received within: 30000 millis. Exchange[GenericFileMessage with body: Bye 1hello2]
>>       at org.apache.camel.component.netty.handlers.ClientChannelHandler.exceptionCaught(ClientChannelHandler.java:79)
>>       at org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:122)
>>       at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:545)
>>       at org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:754)
>>       at org.jboss.netty.handler.codec.oneone.OneToOneDecoder.handleUpstream(OneToOneDecoder.java:66)
>>       at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:545)
>>       at org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:754)
>>       at org.jboss.netty.handler.codec.frame.FrameDecoder.exceptionCaught(FrameDecoder.java:238)
>>       at org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:122)
>>       at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:545)
>>       at org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:754)
>>       at org.jboss.netty.channel.Channels.fireExceptionCaught(Channels.java:443)
>>       at org.jboss.netty.handler.timeout.ReadTimeoutHandler.readTimedOut(ReadTimeoutHandler.java:210)
>>       at org.jboss.netty.handler.timeout.ReadTimeoutHandler$ReadTimeoutTask.run(ReadTimeoutHandler.java:237)
>>       at org.jboss.netty.util.HashedWheelTimer$HashedWheelTimeout.expire(HashedWheelTimer.java:504)
>>       at org.jboss.netty.util.HashedWheelTimer$Worker.notifyExpiredTimeouts(HashedWheelTimer.java:419)
>>       at org.jboss.netty.util.HashedWheelTimer$Worker.run(HashedWheelTimer.java:369)
>>       at org.jboss.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnable.java:108)
>>       at java.lang.Thread.run(Thread.java:595)
>>
>>
>
>



-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

RE: netty issue

Posted by Sadanand Kusma <sk...@ARCCorp.com>.
I am using 2.4. I have thread as 1 because I can establish only single connection with external server. Using that single connection, I can send multiple requests messages one after the other without waiting for responses and need to receive corresponding responses asynchronously. Each message would have a tracking number to relate request and corresponding response.



-----Original Message-----
From: Claus Ibsen [mailto:claus.ibsen@gmail.com] 
Sent: Thursday, August 19, 2010 10:48 AM
To: users@camel.apache.org
Subject: Re: netty issue

What version of Camel are you using?

And why do you have threads(1) in the route?

On Thu, Aug 19, 2010 at 4:45 PM, Sadanand Kusma <sk...@arccorp.com> wrote:
> Thanks for the response, if you set sync=true doesn't it make a synchronous call.
> Are you saying that it always runs in a async mode?,how do we tell it to run in an async mode?.
>
> -----Original Message-----
> From: Willem Jiang [mailto:willem.jiang@gmail.com]
> Sent: Wednesday, August 18, 2010 10:43 PM
> To: users@camel.apache.org
> Subject: Re: netty issue
>
> I just checked the netty's doc and camel-netty producer's code, if you
> set the sync=false, the producer will never expect the response, and the
>  async callback will never be called.
>
> So you just need to change your route like this
>
>  from("file:///test/test/response")
>              .convertBodyTo(String.class)
>              .threads(1)
>              .to("netty:tcp://localhost:6205?textline=true&sync=true")
>              .to("log:+++ reply++++");
>
>
> Willem
>
> Sadanand Kusma wrote:
>> I am actually trying out asynchronous messaging with Netty producer. I get below exception even though sync =false. Also, Is this  the right way to implement asynchronous processing.
>> Here is my route:
>>             from("netty:tcp://localhost:6205?textline=true&sync=true").process(new Processor() {
>>                 int i=0;
>>                   public void process(Exchange exchange) throws Exception {
>>                     String body = exchange.getIn().getBody(String.class);
>>                         Thread.sleep(2000);
>>                     exchange.getOut().setBody("Bye 1" + body);
>>                 }
>>             });
>>
>>             from("file:///test/test/response")
>>             .convertBodyTo(String.class)
>>             .threads(1)
>>             .to("netty:tcp://localhost:6205?textline=true&sync=false")
>>             .to("log:+++ reply++++");
>>
>>
>> org.apache.camel.ExchangeTimedOutException: The OUT message was not received within: 30000 millis. Exchange[GenericFileMessage with body: Bye 1hello2]
>>       at org.apache.camel.component.netty.handlers.ClientChannelHandler.exceptionCaught(ClientChannelHandler.java:79)
>>       at org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:122)
>>       at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:545)
>>       at org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:754)
>>       at org.jboss.netty.handler.codec.oneone.OneToOneDecoder.handleUpstream(OneToOneDecoder.java:66)
>>       at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:545)
>>       at org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:754)
>>       at org.jboss.netty.handler.codec.frame.FrameDecoder.exceptionCaught(FrameDecoder.java:238)
>>       at org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:122)
>>       at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:545)
>>       at org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:754)
>>       at org.jboss.netty.channel.Channels.fireExceptionCaught(Channels.java:443)
>>       at org.jboss.netty.handler.timeout.ReadTimeoutHandler.readTimedOut(ReadTimeoutHandler.java:210)
>>       at org.jboss.netty.handler.timeout.ReadTimeoutHandler$ReadTimeoutTask.run(ReadTimeoutHandler.java:237)
>>       at org.jboss.netty.util.HashedWheelTimer$HashedWheelTimeout.expire(HashedWheelTimer.java:504)
>>       at org.jboss.netty.util.HashedWheelTimer$Worker.notifyExpiredTimeouts(HashedWheelTimer.java:419)
>>       at org.jboss.netty.util.HashedWheelTimer$Worker.run(HashedWheelTimer.java:369)
>>       at org.jboss.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnable.java:108)
>>       at java.lang.Thread.run(Thread.java:595)
>>
>>
>
>



-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Re: netty issue

Posted by Claus Ibsen <cl...@gmail.com>.
What version of Camel are you using?

And why do you have threads(1) in the route?

On Thu, Aug 19, 2010 at 4:45 PM, Sadanand Kusma <sk...@arccorp.com> wrote:
> Thanks for the response, if you set sync=true doesn't it make a synchronous call.
> Are you saying that it always runs in a async mode?,how do we tell it to run in an async mode?.
>
> -----Original Message-----
> From: Willem Jiang [mailto:willem.jiang@gmail.com]
> Sent: Wednesday, August 18, 2010 10:43 PM
> To: users@camel.apache.org
> Subject: Re: netty issue
>
> I just checked the netty's doc and camel-netty producer's code, if you
> set the sync=false, the producer will never expect the response, and the
>  async callback will never be called.
>
> So you just need to change your route like this
>
>  from("file:///test/test/response")
>              .convertBodyTo(String.class)
>              .threads(1)
>              .to("netty:tcp://localhost:6205?textline=true&sync=true")
>              .to("log:+++ reply++++");
>
>
> Willem
>
> Sadanand Kusma wrote:
>> I am actually trying out asynchronous messaging with Netty producer. I get below exception even though sync =false. Also, Is this  the right way to implement asynchronous processing.
>> Here is my route:
>>             from("netty:tcp://localhost:6205?textline=true&sync=true").process(new Processor() {
>>                 int i=0;
>>                   public void process(Exchange exchange) throws Exception {
>>                     String body = exchange.getIn().getBody(String.class);
>>                         Thread.sleep(2000);
>>                     exchange.getOut().setBody("Bye 1" + body);
>>                 }
>>             });
>>
>>             from("file:///test/test/response")
>>             .convertBodyTo(String.class)
>>             .threads(1)
>>             .to("netty:tcp://localhost:6205?textline=true&sync=false")
>>             .to("log:+++ reply++++");
>>
>>
>> org.apache.camel.ExchangeTimedOutException: The OUT message was not received within: 30000 millis. Exchange[GenericFileMessage with body: Bye 1hello2]
>>       at org.apache.camel.component.netty.handlers.ClientChannelHandler.exceptionCaught(ClientChannelHandler.java:79)
>>       at org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:122)
>>       at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:545)
>>       at org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:754)
>>       at org.jboss.netty.handler.codec.oneone.OneToOneDecoder.handleUpstream(OneToOneDecoder.java:66)
>>       at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:545)
>>       at org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:754)
>>       at org.jboss.netty.handler.codec.frame.FrameDecoder.exceptionCaught(FrameDecoder.java:238)
>>       at org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:122)
>>       at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:545)
>>       at org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:754)
>>       at org.jboss.netty.channel.Channels.fireExceptionCaught(Channels.java:443)
>>       at org.jboss.netty.handler.timeout.ReadTimeoutHandler.readTimedOut(ReadTimeoutHandler.java:210)
>>       at org.jboss.netty.handler.timeout.ReadTimeoutHandler$ReadTimeoutTask.run(ReadTimeoutHandler.java:237)
>>       at org.jboss.netty.util.HashedWheelTimer$HashedWheelTimeout.expire(HashedWheelTimer.java:504)
>>       at org.jboss.netty.util.HashedWheelTimer$Worker.notifyExpiredTimeouts(HashedWheelTimer.java:419)
>>       at org.jboss.netty.util.HashedWheelTimer$Worker.run(HashedWheelTimer.java:369)
>>       at org.jboss.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnable.java:108)
>>       at java.lang.Thread.run(Thread.java:595)
>>
>>
>
>



-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

RE: netty issue

Posted by Sadanand Kusma <sk...@ARCCorp.com>.
Thanks for the response, if you set sync=true doesn't it make a synchronous call. 
Are you saying that it always runs in a async mode?,how do we tell it to run in an async mode?.

-----Original Message-----
From: Willem Jiang [mailto:willem.jiang@gmail.com] 
Sent: Wednesday, August 18, 2010 10:43 PM
To: users@camel.apache.org
Subject: Re: netty issue

I just checked the netty's doc and camel-netty producer's code, if you 
set the sync=false, the producer will never expect the response, and the 
  async callback will never be called.

So you just need to change your route like this

  from("file:///test/test/response")
              .convertBodyTo(String.class)
              .threads(1)
              .to("netty:tcp://localhost:6205?textline=true&sync=true")
              .to("log:+++ reply++++");


Willem

Sadanand Kusma wrote:
> I am actually trying out asynchronous messaging with Netty producer. I get below exception even though sync =false. Also, Is this  the right way to implement asynchronous processing.
> Here is my route:
>             from("netty:tcp://localhost:6205?textline=true&sync=true").process(new Processor() {
>                 int i=0;
>                   public void process(Exchange exchange) throws Exception {
>                     String body = exchange.getIn().getBody(String.class);
>                         Thread.sleep(2000);
>                     exchange.getOut().setBody("Bye 1" + body);
>                 }
>             });
> 
>             from("file:///test/test/response")
>             .convertBodyTo(String.class)
>             .threads(1)
>             .to("netty:tcp://localhost:6205?textline=true&sync=false")
>             .to("log:+++ reply++++");
> 
> 
> org.apache.camel.ExchangeTimedOutException: The OUT message was not received within: 30000 millis. Exchange[GenericFileMessage with body: Bye 1hello2]
>       at org.apache.camel.component.netty.handlers.ClientChannelHandler.exceptionCaught(ClientChannelHandler.java:79)
>       at org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:122)
>       at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:545)
>       at org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:754)
>       at org.jboss.netty.handler.codec.oneone.OneToOneDecoder.handleUpstream(OneToOneDecoder.java:66)
>       at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:545)
>       at org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:754)
>       at org.jboss.netty.handler.codec.frame.FrameDecoder.exceptionCaught(FrameDecoder.java:238)
>       at org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:122)
>       at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:545)
>       at org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:754)
>       at org.jboss.netty.channel.Channels.fireExceptionCaught(Channels.java:443)
>       at org.jboss.netty.handler.timeout.ReadTimeoutHandler.readTimedOut(ReadTimeoutHandler.java:210)
>       at org.jboss.netty.handler.timeout.ReadTimeoutHandler$ReadTimeoutTask.run(ReadTimeoutHandler.java:237)
>       at org.jboss.netty.util.HashedWheelTimer$HashedWheelTimeout.expire(HashedWheelTimer.java:504)
>       at org.jboss.netty.util.HashedWheelTimer$Worker.notifyExpiredTimeouts(HashedWheelTimer.java:419)
>       at org.jboss.netty.util.HashedWheelTimer$Worker.run(HashedWheelTimer.java:369)
>       at org.jboss.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnable.java:108)
>       at java.lang.Thread.run(Thread.java:595)
> 
> 


Re: netty issue

Posted by Willem Jiang <wi...@gmail.com>.
I just checked the netty's doc and camel-netty producer's code, if you 
set the sync=false, the producer will never expect the response, and the 
  async callback will never be called.

So you just need to change your route like this

  from("file:///test/test/response")
              .convertBodyTo(String.class)
              .threads(1)
              .to("netty:tcp://localhost:6205?textline=true&sync=true")
              .to("log:+++ reply++++");


Willem

Sadanand Kusma wrote:
> I am actually trying out asynchronous messaging with Netty producer. I get below exception even though sync =false. Also, Is this  the right way to implement asynchronous processing.
> Here is my route:
>             from("netty:tcp://localhost:6205?textline=true&sync=true").process(new Processor() {
>                 int i=0;
>                   public void process(Exchange exchange) throws Exception {
>                     String body = exchange.getIn().getBody(String.class);
>                         Thread.sleep(2000);
>                     exchange.getOut().setBody("Bye 1" + body);
>                 }
>             });
> 
>             from("file:///test/test/response")
>             .convertBodyTo(String.class)
>             .threads(1)
>             .to("netty:tcp://localhost:6205?textline=true&sync=false")
>             .to("log:+++ reply++++");
> 
> 
> org.apache.camel.ExchangeTimedOutException: The OUT message was not received within: 30000 millis. Exchange[GenericFileMessage with body: Bye 1hello2]
>       at org.apache.camel.component.netty.handlers.ClientChannelHandler.exceptionCaught(ClientChannelHandler.java:79)
>       at org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:122)
>       at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:545)
>       at org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:754)
>       at org.jboss.netty.handler.codec.oneone.OneToOneDecoder.handleUpstream(OneToOneDecoder.java:66)
>       at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:545)
>       at org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:754)
>       at org.jboss.netty.handler.codec.frame.FrameDecoder.exceptionCaught(FrameDecoder.java:238)
>       at org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:122)
>       at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:545)
>       at org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:754)
>       at org.jboss.netty.channel.Channels.fireExceptionCaught(Channels.java:443)
>       at org.jboss.netty.handler.timeout.ReadTimeoutHandler.readTimedOut(ReadTimeoutHandler.java:210)
>       at org.jboss.netty.handler.timeout.ReadTimeoutHandler$ReadTimeoutTask.run(ReadTimeoutHandler.java:237)
>       at org.jboss.netty.util.HashedWheelTimer$HashedWheelTimeout.expire(HashedWheelTimer.java:504)
>       at org.jboss.netty.util.HashedWheelTimer$Worker.notifyExpiredTimeouts(HashedWheelTimer.java:419)
>       at org.jboss.netty.util.HashedWheelTimer$Worker.run(HashedWheelTimer.java:369)
>       at org.jboss.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnable.java:108)
>       at java.lang.Thread.run(Thread.java:595)
> 
>