Hi Claus,

thanks for your answer. The need for dictating an order comes from structuring 
my routes into multiple logical blocks and connecting them via the direct 
component.

The first route is for consuming messages via JMS, the next route is for 
grouping the messages and the last route is for persisting each group to a 
database (for example, there are more routes in between which I didn't list 
here). When the first one for consuming the messages starts, consumes a message 
and sends it to the route which is grouping them, the other route might not 
have been started yet, hence why I get this exception:

        org.apache.camel.component.direct.DirectConsumerNotAvailableException: 
No consumers available on endpoint: direct://my-route. Exchange[ID-<id>]

Using the startupOrder feature helps me to prevent this from happening. Also, 
structuring my routes like that makes it easer to inject messages in between 
routes via the ProducerTemplate and it also makes it easier to advice my routes 
for testing.

I guess you're right, I could declare my routes in the correct order in which 
they should be started. However I think it is more intuitive and readable to 
declare my routes in the order of message flow instead. Therefore I don't think 
that this would be a solution for me.

Best regards,
Jannik

-----Ursprüngliche Nachricht-----
Von: Claus Ibsen <claus.ib...@gmail.com> 
Gesendet: Freitag, 28. April 2023 16:01
An: users@camel.apache.org
Betreff: Re: Adding route builder when camel is already started doesn't respect 
startup order

Hi

The startupOrder feature was intended in earlier days when some components had 
to be started before others. But Camel in general is starting up things better 
over the years, and this feature is much less in need.

So what is it that you have in your routes that you think you need to dictate 
an order? And you can also structure your routes in the RouteBuilder from top 
to bottoom in the order you need.

On Fri, Apr 28, 2023 at 3:24 PM Schmeier, Jannik <j.schme...@fraport.de>
wrote:

> Hi all,
>
> I'm using Apache Camel 3.4.4 in a Spring Boot 2.3.12 application. I 
> know, that these aren't the most recent versions, but I'm currently 
> not able to update to newer ones.
>
> I'm trying to add a route builder dynamically after the camel context 
> has already been started like so:
>
>         camelContext.addRoutes(routeBuilder);
>
> In general this is working and my routes are being added and started.
> However, adding a route builder like that doesn't seem to respect the 
> startup orders that I have defined for my routes in that route builder.
> They're being started in the order that they're defined in the route 
> builder.
>
> The issue seems to be that inside this method
> https://github.com/apache/camel/blob/camel-3.4.4/core/camel-core-engin
> e/src/main/java/org/apache/camel/impl/DefaultCamelContext.java#L346
> the route services are being started one after the other and not all 
> together, resulting in the call to the internal startup order manager 
> in
> https://github.com/apache/camel/blob/camel-3.4.4/core/camel-base/src/m
> ain/java/org/apache/camel/impl/engine/AbstractCamelContext.java#L3070
> basically being useless.
>
> Does anyone know a way around this in Camel 3.4.4?
>
> Best regards,
> Jannik
>
>

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

Reply via email to