You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by "S. Ali Tokmen" <sa...@bull.net> on 2010/01/08 16:31:47 UTC

Interceptor not working for manually created echanges

Hello

I'm currently using CAMEL 2.0.0 with a route that dynamically splits and 
routes a message to many destinations. I should be using a 
recipientList() but since the version 2.0.0 doesn't allow any exception 
handling I'm forced to using a construct like the following:

     for (Map.Entry<String, Message> destination : 
destinations.entrySet()) {
         Producer expediteur = 
exchange.getContext().getEndpoint(destination.getKey()).createProducer();
         Exchange envoi = expediteur.createExchange();
         envoi.setIn(destination.getValue());
         expediteur.process(envoi);
     }

This actually works, and the outer processor gets an exception if any 
destination fails.

Here's the issue: in my original context, I had a tracer defined like 
the following:

     // Tracer, that will by default log on log4j and send to the
     // fr.bull.cetebordeaux.traces JMS queue
     Tracer tracer = new Tracer();
     tracer.setFormatter(new CETEMessageFormatter());
     tracer.setLogLevel(LoggingLevel.INFO);
     tracer.setLogName("fr.bull.cetebordeaux.traces");
     tracer.setDestinationUri("direct:traced");
     this.from("direct:traced").process(new 
DefaultTraceEventMessageToStringProcessor()).to("registry:Trace.Queue");
     this.getContext().addInterceptStrategy(tracer);

That tracer is actually not active for the Exchange I've created 
"manually". Is this an expected behaviour?

Cheers

-- 

S. Ali Tokmen
savas-ali.tokmen@bull.net

Office: +33 4 76 29 76 19
GSM:    +33 66 43 00 555

Bull, Architect of an Open World TM
http://www.bull.com



Re: Interceptor not working for manually created echanges

Posted by "S. Ali Tokmen" <sa...@bull.net>.
Hello again

Sorry for the late reply...

Le 11/01/2010 10:08, Claus Ibsen a écrit :
>
>> Is the onException clause declared for the context supposed to work for the manual code?
>>      
> No all that is only applicable for routes.
>    

That's good to know. In my case, since I had started the process launch 
inside a .process(...) method, any exception thrown gets thrown back to 
the original route.

I'm happy now :)

Cheers

S. Ali Tokmen
savas-ali.tokmen@bull.net

Office: +33 4 76 29 76 19
GSM:    +33 66 43 00 555

Bull, Architect of an Open World TM
http://www.bull.com



Re: Interceptor not working for manually created echanges

Posted by Claus Ibsen <cl...@gmail.com>.
On Mon, Jan 11, 2010 at 9:01 AM, S. Ali Tokmen
<sa...@bull.net> wrote:
> Hello
>
> Le 10/01/2010 09:43, Claus Ibsen a écrit :
>>
>> The tracer works on the routes only. So it gets activated when any
>> Exchange gets routed to a Camel route.
>>
>> So if you custom code send the Exchange to a "direct:foo" endpoint
>> which then has a route then it should get traced
>>
>> from("direct:foo").to("bean:foo").to("bean:bar");
>>
>> Then it should trace the routing direct:foo ->  bean:foo ->  bean:bar.
>> But NOT the manual code you did to send the Exchange to the direct:foo
>> endpoint.
>>
>
> OK, this means things are working as expected. Is the onException clause
> declared for the context supposed to work for the manual code?

No all that is only applicable for routes.

>
> By the way, is there a way of adding in the tracer for the manual code?
>

No Tracer is done on routes only as well.




> Cheers
>
> S. Ali Tokmen
> savas-ali.tokmen@bull.net
>
> Office: +33 4 76 29 76 19
> GSM:    +33 66 43 00 555
>
> Bull, Architect of an Open World TM
> http://www.bull.com
>
>
>
>



-- 
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: Interceptor not working for manually created echanges

Posted by "S. Ali Tokmen" <sa...@bull.net>.
Hello

Le 10/01/2010 09:43, Claus Ibsen a écrit :
> The tracer works on the routes only. So it gets activated when any
> Exchange gets routed to a Camel route.
>
> So if you custom code send the Exchange to a "direct:foo" endpoint
> which then has a route then it should get traced
>
> from("direct:foo").to("bean:foo").to("bean:bar");
>
> Then it should trace the routing direct:foo ->  bean:foo ->  bean:bar.
> But NOT the manual code you did to send the Exchange to the direct:foo endpoint.
>    

OK, this means things are working as expected. Is the onException clause 
declared for the context supposed to work for the manual code?

By the way, is there a way of adding in the tracer for the manual code?

Cheers

S. Ali Tokmen
savas-ali.tokmen@bull.net

Office: +33 4 76 29 76 19
GSM:    +33 66 43 00 555

Bull, Architect of an Open World TM
http://www.bull.com




Re: Interceptor not working for manually created echanges

Posted by Claus Ibsen <cl...@gmail.com>.
On Fri, Jan 8, 2010 at 4:31 PM, S. Ali Tokmen <sa...@bull.net> wrote:
> Hello
>
> I'm currently using CAMEL 2.0.0 with a route that dynamically splits and
> routes a message to many destinations. I should be using a recipientList()
> but since the version 2.0.0 doesn't allow any exception handling I'm forced
> to using a construct like the following:
>
>    for (Map.Entry<String, Message> destination : destinations.entrySet()) {
>        Producer expediteur =
> exchange.getContext().getEndpoint(destination.getKey()).createProducer();
>        Exchange envoi = expediteur.createExchange();
>        envoi.setIn(destination.getValue());
>        expediteur.process(envoi);
>    }
>
> This actually works, and the outer processor gets an exception if any
> destination fails.
>
> Here's the issue: in my original context, I had a tracer defined like the
> following:
>
>    // Tracer, that will by default log on log4j and send to the
>    // fr.bull.cetebordeaux.traces JMS queue
>    Tracer tracer = new Tracer();
>    tracer.setFormatter(new CETEMessageFormatter());
>    tracer.setLogLevel(LoggingLevel.INFO);
>    tracer.setLogName("fr.bull.cetebordeaux.traces");
>    tracer.setDestinationUri("direct:traced");
>    this.from("direct:traced").process(new
> DefaultTraceEventMessageToStringProcessor()).to("registry:Trace.Queue");
>    this.getContext().addInterceptStrategy(tracer);
>
> That tracer is actually not active for the Exchange I've created "manually".
> Is this an expected behaviour?
>

The tracer works on the routes only. So it gets activated when any
Exchange gets routed to a Camel route.

So if you custom code send the Exchange to a "direct:foo" endpoint
which then has a route then it should get traced

from("direct:foo").to("bean:foo").to("bean:bar");

Then it should trace the routing direct:foo -> bean:foo -> bean:bar.
But NOT the manual code you did to send the Exchange to the direct:foo endpoint.





> Cheers
>
> --
>
> S. Ali Tokmen
> savas-ali.tokmen@bull.net
>
> Office: +33 4 76 29 76 19
> GSM:    +33 66 43 00 555
>
> Bull, Architect of an Open World TM
> http://www.bull.com
>
>
>



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