camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <claus.ib...@gmail.com>
Subject Re: Delaying start of Endpoint's Producer
Date Sat, 02 Jun 2012 12:02:49 GMT
On Wed, May 30, 2012 at 2:38 PM, Alex Anderson
<alexanderandersonofandover@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

Mime
View raw message