camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <>
Subject Re: How to write a singleton producer
Date Wed, 20 Apr 2011 09:00:04 GMT
On Wed, Apr 20, 2011 at 10:20 AM, andrew.cowper <> wrote:
> Thnaks for your answer Ben, I actually already have that reference in my
> Producer class. The real issue is that I need to call a specific method
> (activate) on the datasource when a certain sentinel message has been
> received once from each route. That is why I want a singleton Producer, so
> that it can count the sentinel messages and activate the datasource when
> they have all been received.
> If there are other ways to go about this, as a Camel newbie I'd be
> interested in any advice.

Just return the shared instance of your producer from the
createProducer method on your custom endpoint.

> Thanks a lot
> Andrew
> ben.oday wrote:
>> I don't think you want to cache the Producer or you'll loose the
>> configuration for subsequent routes (as well as causing other issues I
>> imagine).  Instead, I'd try to use a static (thread-safe) reference to
>> your datasource in your custom Producer class that can be shared across
>> instances.
>> andrew.cowper wrote:
>>> I am trying to have two routes which go to the same producer. Camel is
>>> creating two instances of the Producer though.
>>> How do I stop it doing that? Do I have to write code in my EndPoint to
>>> cache the Producer, and return the existing one when it is requested the
>>> second time? I was expecting camel to be able to cache the Producer for
>>> me.
> --
> View this message in context:
> Sent from the Camel - Users mailing list archive at

Claus Ibsen
CamelOne 2011:
Twitter: davsclaus
Author of Camel in Action:

View raw message