You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Nikola Glidzic <ni...@ikor.one> on 2022/10/05 09:49:56 UTC

BUG in Supervising Route Controller (if not a BUG, then at least a BAD USER EXPERIENCE)

Hello Camel community,

Official docs are saying that Supervising Route Controller tries to start "failed" routes again, but actually it is starting routes that are "stopped". You can find that code in class DefaultSupervisingRouteController, method startSupervisedRoutes(). There is line of code which does routes filtering by checking status "Stopped", but I think it should check for status Failed instead.

There is a bad experience which I have in my case, here I will describe how is this happening on my project and what I am doing:

In our project in one of our special cases we have to put some routes in status SUSPEND and we have to do that before the routes are even started within CamelContext. We have implemented CamelContextConfiguration class and we get 2 CamelContext lifecycle methods. So in lifecycle method afterApplicationStart() we get some routes and suspend them. We can't do this with Default Route Controller because it is too late, routes are somehow already started. That is too late for us, we need to suspend them before they are started! And this is really how we need to do that because of our business logic, we cannot use anything from options on the route (for example .noAutoStartup()).

So because of that Default Route Controller deficiency we use Supervising Route Controller instead, which has stated in official docs: "A supervising capable RouteController that delays the startup of the routes after the camel context startup and takes control of starting the routes in a safe manner."
And this is ok, it works very well and as expected!

Then we are able to do the suspension, but not on all routes. For example route with Kafka consumer is not suspendable, and when you try to suspend components which can't be suspended, they are actually put to STOP status. And here is one sentence from your official java doc from interface RouteController, for method suspendRoute(String id): "If the route does not support suspension the route will be stopped instead".

After this my kafka route will be in status STOPED (which is still ok for us), but after that, there comes DefaultSupervisingRouteController and finds that as "failed" (which is not), and will start it again. So final conclusion and questions is that if I use Supervising Controller, I am not able to suspend or stop some components because they will actually be started again?
Why it is like that? Is that a bug or is it meant to be like that?
Even if you planned to be like that, then it is a bad experience for us, because you simply cannot stop/suspend routes when using Supervising Route Controller.

We are using Camel 3.15 and camel-kafka-starter.

Very interested into topic and happy to hear explanation.
Kind Regards,
Nikola Glidzic





Re: BUG in Supervising Route Controller (if not a BUG, then at least a BAD USER EXPERIENCE)

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

Thanks for the long detailed explanation of your situation.

However what you do is not the normal use-case, where you "trick" camel
with suspending routes via listeners during bootstrap, and then expect
Camel route controller to work after this.

So your use-case is that you want to control which routes to startup (there
is the autoStartup for that) but you do not want to use that, and hence you
are going out of ways.
Its really bad to let Camel start a route and then for you to immediately
suspend/stop the route.

You should look at a way to use autoStartup to configure which routes to
startup. There are many APIs and hooks in Camel, so try to find one that
can work for you, where you can set autoStartup = false on the routes you
do not want to startup.



On Wed, Oct 5, 2022 at 6:03 AM Nikola Glidzic <ni...@ikor.one>
wrote:

> Hello Camel community,
>
> Official docs are saying that Supervising Route Controller tries to start
> "failed" routes again, but actually it is starting routes that are
> "stopped". You can find that code in class
> DefaultSupervisingRouteController, method startSupervisedRoutes(). There is
> line of code which does routes filtering by checking status "Stopped", but
> I think it should check for status Failed instead.
>
> There is a bad experience which I have in my case, here I will describe
> how is this happening on my project and what I am doing:
>
> In our project in one of our special cases we have to put some routes in
> status SUSPEND and we have to do that before the routes are even started
> within CamelContext. We have implemented CamelContextConfiguration class
> and we get 2 CamelContext lifecycle methods. So in lifecycle method
> afterApplicationStart() we get some routes and suspend them. We can't do
> this with Default Route Controller because it is too late, routes are
> somehow already started. That is too late for us, we need to suspend them
> before they are started! And this is really how we need to do that because
> of our business logic, we cannot use anything from options on the route
> (for example .noAutoStartup()).
>
> So because of that Default Route Controller deficiency we use Supervising
> Route Controller instead, which has stated in official docs: "A supervising
> capable RouteController that delays the startup of the routes after the
> camel context startup and takes control of starting the routes in a safe
> manner."
> And this is ok, it works very well and as expected!
>
> Then we are able to do the suspension, but not on all routes. For example
> route with Kafka consumer is not suspendable, and when you try to suspend
> components which can't be suspended, they are actually put to STOP status.
> And here is one sentence from your official java doc from interface
> RouteController, for method suspendRoute(String id): "If the route does not
> support suspension the route will be stopped instead".
>
> After this my kafka route will be in status STOPED (which is still ok for
> us), but after that, there comes DefaultSupervisingRouteController and
> finds that as "failed" (which is not), and will start it again. So final
> conclusion and questions is that if I use Supervising Controller, I am not
> able to suspend or stop some components because they will actually be
> started again?
> Why it is like that? Is that a bug or is it meant to be like that?
> Even if you planned to be like that, then it is a bad experience for us,
> because you simply cannot stop/suspend routes when using Supervising Route
> Controller.
>
> We are using Camel 3.15 and camel-kafka-starter.
>
> Very interested into topic and happy to hear explanation.
> Kind Regards,
> Nikola Glidzic
>
>
>
>
>

-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2