On Mon, Mar 25, 2013 at 9:08 PM, Chris Wolf <[email protected]> wrote:
> I am looking at code in
> org.apache.camel.routepolicy.quartz.ScheduledRoutePolicy -
> the code that starts/stops/resumes/suspends the route it is a policy for.
>
> The question is why is it separately acting on the Consumer? I thought
> if you call
> CamelContext.suspendRoute(route)  and/or CamelContext.resumeRoute(route),
> that all the components in the route are suspended/resumed as well?
>

No a suspend/resume is a "light" action, that keeps the existing
resources "warm".

For example its used by a throttler route policy, to continuously
suspend/resume a route based on metrics.

You use case should use stop|start instead. Only use suspend/resume if
the duration is short, and you want to keep resources "warm".


> Secondly, why does this code assume there is a Consumer?  What if the route 
> has
> a Producer?
>

All routes starts from a consumer.


> I am not being critical - I just want to understand, generally how
> route suspend/resume works
> since I am implementing a similar RoutePolicy.
>

See the lifecycle documentation
http://camel.apache.org/lifecycle


> Thanks,
>
>
>    -Chris
>
>
>  protected void onJobExecute(Action action, Route route) throws Exception {
> [...]
>         } else if (action == Action.SUSPEND) {
>             if (routeStatus == ServiceStatus.Started) {
>                 stopConsumer(route.getConsumer());
>             } else {
>                 LOG.warn("Route is not in a started state and cannot
> be suspended. The current route state is {}", routeStatus);
>             }
>         } else if (action == Action.RESUME) {
>             if (routeStatus == ServiceStatus.Started) {
>                 if (ServiceHelper.isSuspended(route.getConsumer())) {
>                     startConsumer(route.getConsumer());
>                 } else {
>                     LOG.warn("The Consumer {} is not suspended and
> cannot be resumed.", route.getConsumer());
>                 }
>
> [...]



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
FuseSource is now part of Red Hat
Email: [email protected]
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Reply via email to