Hi

This is correct as-is. You should not have duplicate ids, its your problem
to fix that.

On Tue, Apr 16, 2024 at 9:23 AM Michael Rambichler <mich...@rambichler.at>
wrote:

> Hi,
>
>
>
> we recently switched from Camel 3.18 to Camel 3.22 and we discovered
> following issue in some of our applications:
>
>
>
> We have several applications that use e.g. openapi generator to create
> separate route builder classes, a minimal reproducible example is:
>
>
>
> @Component
>
> public final class RestRoute extends RouteBuilder {
>
>     public void configure() {
>
>         rest().get().id("myRoute1").to("log:foo");
>
>     }
>
> }
>
>
>
> The id “myRoute1” is specified over the operationId in the open API spec.
> Furthermore, we have following “main” route using the same route ID (not on
> purpose):
>
>
>
> @Component
>
> public class MainRoute extends RouteBuilder {
>
>     public void configure() {
>
>         from("direct:myRoute1").routeId("myRoute1").to("log:bar");
>
>     }
>
> }
>
>
>
> The routeId in this route is typically set over config. Both routes use the
> same ID (which is not easy to detect in an application if REST route is
> auto-generated and main route gets ID from config). In Camel 3.18, we did
> not have a problem with that.
>
>
>
> However, in Camel 3.22, running a simple unit test shows a
> non-deterministic behavior:
>
>
>
>    1. If RestRoute is configured first, it gets the ID “myRoute1” assigned.
>    Afterwards, MainRoute is configured, and detects that “myRoute1” is
> already
>    used, and throws an Exception:
>
> FailedToStartRouteException: Failed to start route myRoute1 because of
> duplicate id detected: myRoute1.
>
>
>
>    2. If MainRoute is configured first, it gets the ID “myRoute1” assigned.
>    Afterwards, RestRoute is configured, and detects that “myRoute1” is
> already
>    used, and then assigns a new route ID to RestRoute (“route1”). No
> problem
>    arises here.
>
>
>
> The problem is that the result varies from run to run. We had the
> situation, that in local unit test and test pipeline, the tests were
> running fine, but in the production deployment the test suddenly failed.
>
> Even worse is that the application startup would also fail if RestRoute is
> configured first.
>
>
>
> Another problem in Camel 3.22 we discovered in our tests was that if
> RestRoute uses .routeId() instead of .id(), e.g.
> rest().get().routeId("myRoute1").to("log:foo"), then one of the two routes
> will not start at all, without throwing an error.
>
> Here, the route that is configured first starts, and the other route won’t
> start. In Camel 3.18, .routeId() is not available for rest routes at all,
> so no problem there.
>
>
>
> So, it looks like the order of route configuration was deterministic in
> Camel 3.18 (here, it seems the route configuration order depended on the
> name of the class or the package the class is in).
>
> In Camel 3.22 it seems this is not deterministic anymore, leading to
> above-described problems.
>
>
>
> Please let us know if this behavior is known and if I should create a
> ticket for it.
>
>
>
> Thanks
>


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

Reply via email to