camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From James Strachan <>
Subject Re: question: best practice to use camel's Producer class
Date Thu, 10 Dec 2009 14:51:56 GMT
2009/12/10 Nick Chistyakov <>:
> Hi guys,
> What is actually the best practice to use camel's Producer class?
> Is it expensive to create, for example, to create it every time when message
> is processed.
> Or is it better to store a reference to it somewhere in a class scope?

FWIW typically you don't need to implement a Processor as you can use
the bean binding instead and just invoke regular java bean methods,

allowing you to use the annotations to extract the various things from
the message you want which simplifies your code and also means you can
hide the Camel APIs. We should strive to write application code
without any explicit middleware APIs where possible as its easier to
understand and test

In terms of whether you should use a singleton instance of a
bean/processor or not, if you are using spring/guice then you can
specify this in the IoC container. Camel will use Spring/Guice to get
an instance of your bean - which allows each instance to be stateful
if you like (e.g. injecting a new database connection or whatever) to
avoid concurrency issues when sharing the same bean instance - or if
you prefer it can be a singleton.


Open Source Integration

View raw message