camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <claus.ib...@gmail.com>
Subject Re: Deep stack for simple route
Date Fri, 30 Dec 2011 12:50:31 GMT
On Fri, Dec 30, 2011 at 11:49 AM, Jason Dillon <jason@planet57.com> wrote:
> On Dec 30, 2011, at 2:14 AM, Claus Ibsen wrote:
>> On Fri, Dec 30, 2011 at 9:54 AM, Jason Dillon <jason@planet57.com> wrote:
>>> On Dec 29, 2011, at 5:42 PM, Willem Jiang wrote:
>>>> There are some default interceptors, processor wrappers are used to help
camel to implement the error handling and async processing.
>>>
>>> What is async about the route below?  I'd imagine that the route flow:
>>>
>>> producer-template -> direct -> direct -> processor
>>>
>>> ... would be completely sync.   Is there some async behavior hiding in here?
>>
>> Its the Camel routing engine underneath that adds in behavior to
>> control the routing, and deal with interceptors, tracing, error
>> handling, asynchronous non-blocking routing and whatnot.
>
> Ya I understand that.  I'm still not sure how all of the async* bits come in to play.
 Perhaps those are the same bits which would be used if it was async or not?
>
> Just wasn't sure from looking at the stack that perhaps I missed some configuration to
optimize messaging handling these very simple routes.
>

The class names which indicate AsyncXXX but they are part of the
asynchronous non-blocking routing engine, which supports regular
synchronous routing as well. So Camel will by default uses these
AsyncXXX classes for routing to support both async and sync.

And mind that the behavior can change during routing, in case a
component leverages async non blocking processing, such as CXF, Jetty,
JMS etc. So a message could have been picked up from a file component
which is sync, and then the routing goes async because the file is
send to a CXF endpoint, etc.


> --jason
>
>
>>>> On Fri Dec 30 03:56:15 2011, Jason Dillon wrote:
>>>>> I'm seeing a very deep stack for a simple route and I'm wondering...
why it is so deep?
>>>>>
>>>>> Testing with a class like:
>>>>>
>>>>> <snip>
>>>>> public class BasicCamelTrial
>>>>>     extends TestSupport
>>>>> {
>>>>>     @Test
>>>>>     public void showStackDepthForSimpleRoute() throws Exception {
>>>>>         DefaultCamelContext camel = new DefaultCamelContext();
>>>>>         camel.disableJMX();
>>>>>         camel.addRoutes(new RouteBuilder()
>>>>>         {
>>>>>             @Override
>>>>>             public void configure() throws Exception {
>>>>>                 from("direct:foo").to("direct:bar");
>>>>>                 from("direct:bar").process(new Processor()
>>>>>                 {
>>>>>                     @Override
>>>>>                     public void process(Exchange exchange)
throws Exception {
>>>>>                         Throwable t = new Throwable("MARKER");
>>>>>                         log("HERE; stack size: {}", t.getStackTrace().length,
t);
>>>>>                     }
>>>>>                 });
>>>>>             }
>>>>>         });
>>>>>
>>>>>         camel.start();
>>>>>
>>>>>         ProducerTemplate producer = camel.createProducerTemplate();
>>>>>         producer.sendBody("direct:foo", "Hello");
>>>>>         producer.stop();
>>>>>
>>>>>         camel.stop();
>>>>>     }
>>>>> }
>>>>> </snip>
>>>>>
>>>>> Shows stack is:
>>>>>
>>>>> <snip>
>>>>> java.lang.Throwable: MARKER
>>>>>      at BasicCamelTrial$1$1.process(BasicCamelTrial.java:39) [test-classes/:na]
>>>>>      at org.apache.camel.impl.converter.AsyncProcessorTypeConverter$ProcessorToAsyncProcessorBridge.process(AsyncProcessorTypeConverter.java:50)
[camel-core-2.8.3.jar:2.8.3]
>>>>>      at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:78)
[camel-core-2.8.3.jar:2.8.3]
>>>>>      at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:98)
[camel-core-2.8.3.jar:2.8.3]
>>>>>      at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:89)
[camel-core-2.8.3.jar:2.8.3]
>>>>>      at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:78)
[camel-core-2.8.3.jar:2.8.3]
>>>>>      at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:98)
[camel-core-2.8.3.jar:2.8.3]
>>>>>      at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:89)
[camel-core-2.8.3.jar:2.8.3]
>>>>>      at org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:90)
[camel-core-2.8.3.jar:2.8.3]
>>>>>      at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:78)
[camel-core-2.8.3.jar:2.8.3]
>>>>>      at org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:318)
[camel-core-2.8.3.jar:2.8.3]
>>>>>      at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:209)
[camel-core-2.8.3.jar:2.8.3]
>>>>>      at org.apache.camel.processor.DefaultChannel.process(DefaultChannel.java:306)
[camel-core-2.8.3.jar:2.8.3]
>>>>>      at org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:111)
[camel-core-2.8.3.jar:2.8.3]
>>>>>      at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:78)
[camel-core-2.8.3.jar:2.8.3]
>>>>>      at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:98)
[camel-core-2.8.3.jar:2.8.3]
>>>>>      at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:89)
[camel-core-2.8.3.jar:2.8.3]
>>>>>      at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:69)
[camel-core-2.8.3.jar:2.8.3]
>>>>>      at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:78)
[camel-core-2.8.3.jar:2.8.3]
>>>>>      at org.apache.camel.component.direct.DirectProducer.process(DirectProducer.java:61)
[camel-core-2.8.3.jar:2.8.3]
>>>>>      at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:78)
[camel-core-2.8.3.jar:2.8.3]
>>>>>      at org.apache.camel.processor.SendProcessor$2.doInAsyncProducer(SendProcessor.java:114)
[camel-core-2.8.3.jar:2.8.3]
>>>>>      at org.apache.camel.impl.ProducerCache.doInAsyncProducer(ProducerCache.java:284)
[camel-core-2.8.3.jar:2.8.3]
>>>>>      at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:109)
[camel-core-2.8.3.jar:2.8.3]
>>>>>      at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:78)
[camel-core-2.8.3.jar:2.8.3]
>>>>>      at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:98)
[camel-core-2.8.3.jar:2.8.3]
>>>>>      at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:89)
[camel-core-2.8.3.jar:2.8.3]
>>>>>      at org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:90)
[camel-core-2.8.3.jar:2.8.3]
>>>>>      at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:78)
[camel-core-2.8.3.jar:2.8.3]
>>>>>      at org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:318)
[camel-core-2.8.3.jar:2.8.3]
>>>>>      at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:209)
[camel-core-2.8.3.jar:2.8.3]
>>>>>      at org.apache.camel.processor.DefaultChannel.process(DefaultChannel.java:306)
[camel-core-2.8.3.jar:2.8.3]
>>>>>      at org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:111)
[camel-core-2.8.3.jar:2.8.3]
>>>>>      at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:78)
[camel-core-2.8.3.jar:2.8.3]
>>>>>      at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:98)
[camel-core-2.8.3.jar:2.8.3]
>>>>>      at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:89)
[camel-core-2.8.3.jar:2.8.3]
>>>>>      at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:69)
[camel-core-2.8.3.jar:2.8.3]
>>>>>      at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:78)
[camel-core-2.8.3.jar:2.8.3]
>>>>>      at org.apache.camel.component.direct.DirectProducer.process(DirectProducer.java:61)
[camel-core-2.8.3.jar:2.8.3]
>>>>>      at org.apache.camel.processor.UnitOfWorkProcessor.processAsync(UnitOfWorkProcessor.java:139)
[camel-core-2.8.3.jar:2.8.3]
>>>>>      at org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:106)
[camel-core-2.8.3.jar:2.8.3]
>>>>>      at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:104)
[camel-core-2.8.3.jar:2.8.3]
>>>>>      at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:85)
[camel-core-2.8.3.jar:2.8.3]
>>>>>      at org.apache.camel.processor.UnitOfWorkProducer.process(UnitOfWorkProducer.java:63)
[camel-core-2.8.3.jar:2.8.3]
>>>>>      at org.apache.camel.impl.ProducerCache$2.doInProducer(ProducerCache.java:351)
[camel-core-2.8.3.jar:2.8.3]
>>>>>      at org.apache.camel.impl.ProducerCache$2.doInProducer(ProducerCache.java:323)
[camel-core-2.8.3.jar:2.8.3]
>>>>>      at org.apache.camel.impl.ProducerCache.doInProducer(ProducerCache.java:222)
[camel-core-2.8.3.jar:2.8.3]
>>>>>      at org.apache.camel.impl.ProducerCache.sendExchange(ProducerCache.java:323)
[camel-core-2.8.3.jar:2.8.3]
>>>>>      at org.apache.camel.impl.ProducerCache.send(ProducerCache.java:168)
[camel-core-2.8.3.jar:2.8.3]
>>>>>      at org.apache.camel.impl.DefaultProducerTemplate.send(DefaultProducerTemplate.java:110)
[camel-core-2.8.3.jar:2.8.3]
>>>>>      at org.apache.camel.impl.DefaultProducerTemplate.sendBody(DefaultProducerTemplate.java:123)
[camel-core-2.8.3.jar:2.8.3]
>>>>>      at org.apache.camel.impl.DefaultProducerTemplate.sendBody(DefaultProducerTemplate.java:130)
[camel-core-2.8.3.jar:2.8.3]
>>>>>      at BasicCamelTrial.showStackDepthForSimpleRoute(BasicCamelTrial.java:48)
[test-classes/:na]
>>>>> ... trimmed out test launcher ...
>>>>> </snip>
>>>>>
>>>>> I ran with a few other routes (a simple a ->  b) and a more complicated
(a ->  b ->  c) and it looks like each route adds 19 stack trace elements.  Is this
the expected behavior of camel by default?  Is there any way to optimize the message flow
for simple routes?
>>>>>
>>>>> --jason



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

Mime
View raw message