You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by aptesameer <ap...@gmail.com> on 2009/10/01 14:46:25 UTC

Refering exchangeId through POJO for logging

Hi All,

So far I have managed to keep my code as POJOs. I mean there is not a single
line of code in java that hints that camel is being used.(All configuration
sits happily in xml!)

However, it is the logging approach that is bugging me. At present the
logging that takes place through my pojo's cannot log exhange-id of the
message for which the pojo's method is being called.

I want camel-exchange id to be part of every logged statement so that I can
have proper trace of the message in one go. [e.g. grep exchangeId
logFileName]
 
I was thinking over it.. and thought probably, I have to have a simple camel
processor implementation that would set the exchange id in thread local.
Once the exchange id is in thread local, my POJo's can simply get the value
from thread local and log it along with other info.

obviously every route should have <camel:bean ref="logHelper"/> immediately
after <camel:from ref="abc">, so that exchange id would be available for
other beans.

Would be glad to know the opinion about this approach.../ some other
approach that could help me out!

Regards,
Sameer
-- 
View this message in context: http://www.nabble.com/Refering-exchangeId-through-POJO-for-logging-tp25696857p25696857.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Refering exchangeId through POJO for logging

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

Yeah at one point you gotta touch that part of Camel code to get that
exchange id.

Wonder if we should add an @ExchangeId annotation that you can use in
bean parameter binding to get that id?
Might be a bit overkill.

You can use interceptors to put the exchange id on the thread local.
For example interceptFromEndpoint which only intercepts new incoming exchanges.

See more here:
http://davsclaus.blogspot.com/2009/05/on-road-to-camel-20-interceptors-round.html

And the Camel wiki page as well
http://camel.apache.org/intercept.html

Basically something like

<interceptFrom>
   <!-- as its a route you can do anything you like, but we use a low
practical processorRef -->
    <processorRef ref="myExchangeIdGrabber"/>
</interceptFrom>


On Thu, Oct 1, 2009 at 2:46 PM, aptesameer <ap...@gmail.com> wrote:
>
> Hi All,
>
> So far I have managed to keep my code as POJOs. I mean there is not a single
> line of code in java that hints that camel is being used.(All configuration
> sits happily in xml!)
>
> However, it is the logging approach that is bugging me. At present the
> logging that takes place through my pojo's cannot log exhange-id of the
> message for which the pojo's method is being called.
>
> I want camel-exchange id to be part of every logged statement so that I can
> have proper trace of the message in one go. [e.g. grep exchangeId
> logFileName]
>
> I was thinking over it.. and thought probably, I have to have a simple camel
> processor implementation that would set the exchange id in thread local.
> Once the exchange id is in thread local, my POJo's can simply get the value
> from thread local and log it along with other info.
>
> obviously every route should have <camel:bean ref="logHelper"/> immediately
> after <camel:from ref="abc">, so that exchange id would be available for
> other beans.
>
> Would be glad to know the opinion about this approach.../ some other
> approach that could help me out!
>
> Regards,
> Sameer
> --
> View this message in context: http://www.nabble.com/Refering-exchangeId-through-POJO-for-logging-tp25696857p25696857.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



-- 
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Re: Refering exchangeId through POJO for logging

Posted by aptesameer <ap...@gmail.com>.
Hi All,

Claus has replied to this query..
http://www.pubbs.net/apachecamel/200910/251/
http://www.pubbs.net/apachecamel/200910/251/ 

I don't know why it is not being shown on nabble!

@Claus- Thanks for your input! I'll give it a try and will update this post
soon...

Regards,
Sameer



aptesameer wrote:
> 
> Hi All,
> 
> So far I have managed to keep my code as POJOs. I mean there is not a
> single line of code in java that hints that camel is being used.(All
> configuration sits happily in xml!)
> 
> However, it is the logging approach that is bugging me. At present the
> logging that takes place through my pojo's cannot log exhange-id of the
> message for which the pojo's method is being called.
> 
> I want camel-exchange id to be part of every logged statement so that I
> can have proper trace of the message in one go. [e.g. grep exchangeId
> logFileName]
>  
> I was thinking over it.. and thought probably, I have to have a simple
> camel processor implementation that would set the exchange id in thread
> local. Once the exchange id is in thread local, my POJo's can simply get
> the value from thread local and log it along with other info.
> 
> obviously every route should have <camel:bean ref="logHelper"/>
> immediately after <camel:from ref="abc">, so that exchange id would be
> available for other beans.
> 
> Would be glad to know the opinion about this approach.../ some other
> approach that could help me out!
> 
> Regards,
> Sameer
> 

-- 
View this message in context: http://www.nabble.com/Refering-exchangeId-through-POJO-for-logging-tp25696857p25696930.html
Sent from the Camel - Users mailing list archive at Nabble.com.