You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Claus Ibsen <cl...@gmail.com> on 2012/06/02 14:02:49 UTC

Re: Delaying start of Endpoint's Producer

On Wed, May 30, 2012 at 2:38 PM, Alex Anderson
<al...@gmail.com> wrote:
> I have a Producer attached to an Endpoint which takes some time to
> initialise.  Currently there is a bug that the Producer.produce()
> method can be passed messages while the Endpoint is still
> initialising.
>
> Would a correct solution to this be:
> a) block inside Producer.produce() until the endpoint is initialised
> b) throw an Exception in Producer.produce() if the endpoint is not initialised
> c) block inside Endpoint.createProducer() until the endpoint is initialised
> d) something else
>
> Thanks for any answers or thoughts.
>
> Alex

Do you initialization logic in the doStart / doStop method of your
producer, eg if you extend DefaultProducer.
If you do not extend any classes, then either extend ServiceSupport or
implement the Service interface.

See details about lifecycle of services
http://camel.apache.org/lifecycle.html

Then when Camel startup the routes is started, and the logic in
doStart is invoked etc. This ensures the producers
has all been properly started before routing starts.


-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen