camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Willem Jiang <willem.ji...@gmail.com>
Subject Re: Startup invocation of a route
Date Tue, 29 Dec 2009 08:19:21 GMT
Maybe we can add option in camel-quartz to let it fire the trigger when 
the route is started.

Willem

Stephen Gargan wrote:
> Christopher,
> 
> Claus has got you covered ;) There is an EventNotification mechanism
> that you can use. Add the following to your routes configure
> 
> public class InvokedOnStartupRoute extends RouteBuilder {
> 
>     @Override
>     public void configure() throws Exception {
>         final CamelContext context = getContext();
>         context.getManagementStrategy().setEventNotifier(new EventNotifier() {
>             public void notify(EventObject event) throws Exception {
>                if(event instanceof CamelContextStartedEvent)
>                {
>                    ProducerTemplate template = context.createProducerTemplate();
>                    template.sendBody("direct:invokedOnStartup", "Started");
>                }
>             }
>             public boolean isEnabled(EventObject event) {
>                 return true;
>             }
>         });
>         from("direct:invokedOnStartup").to("mock:invokedOnStartup");
>     }
> }
> 
> It might be nice also if there were a method in the LifecycleStrategy
> interface, onInitializationComplete or the like, that fit a similar
> purpose. I'll let Claus comment on that.
> 
> rgds,
> 
> ste
> 
> 
> On Mon, Dec 28, 2009 at 6:06 PM, huntc <huntc@mac.com> wrote:
>> Hi Stephen,
>>
>> Thanks for your response.
>>
>> I do understand the use of the direct component, but thanks for the
>> explanation any how.
>>
>> I guess using the Spring Events mechanism will get me there, but it'd be
>> nice to codify the solution in a way that remains agnostic of being invoked
>> from Spring.
>>
>> I'm thinking that it'd be useful to raise a JIRA so that RouteBuilder gets
>> the opportunity of kicking things off once the context is ready. What'd
>> think?
>>
>> BTW: I do not have a Main class as I'm using org.apache.camel.spring.Main.
>>
>> Kind regards,
>> Christopher
>> --
>> View this message in context: http://old.nabble.com/Startup-invocation-of-a-route-tp26949232p26950280.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>
>>
> 


Mime
View raw message