camel.rest.inline-routes has same route Id

Solution Verified - Updated -

Issue

Build error occurs with the multi rest routers and forward to the same "direct:test".

import org.apache.camel.builder.RouteBuilder;

public class Rest extends RouteBuilder {

    @Override
    public void configure() throws Exception {
        rest("")
           .get("/test1")
           .routeId("test1")
           .to("direct:test");

        rest("")
           .get("/test2")
           .routeId("test2")
           .to("direct:test");

        from("direct:test")
           .routeId("test")
           .log("${body}");

    }
}

It is failing with camel run Rest.java

org.apache.camel.FailedToStartRouteException: Failed to start route test because of duplicate id detected: test. Please correct ids to be unique among all your routes.
at org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:638)
at org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:597)
at org.apache.camel.impl.engine.AbstractCamelContext.doInit(AbstractCamelContext.java:2471)
at org.apache.camel.support.service.BaseService.init(BaseService.java:85)
at org.apache.camel.impl.engine.AbstractCamelContext.init(AbstractCamelContext.java:2101)
at org.apache.camel.support.service.BaseService.start(BaseService.java:115)
at org.apache.camel.impl.engine.AbstractCamelContext.start(AbstractCamelContext.java:2120)
at org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:211)
at org.apache.camel.main.KameletMain.doStart(KameletMain.java:386)
at org.apache.camel.support.service.BaseService.start(BaseService.java:123)
at org.apache.camel.dsl.jbang.core.commands.Run.runKameletMain(Run.java:1493)
at org.apache.camel.dsl.jbang.core.commands.Run.run(Run.java:942)
at org.apache.camel.dsl.jbang.core.commands.Run.doCall(Run.java:347)
at org.apache.camel.dsl.jbang.core.commands.CamelCommand.call(CamelCommand.java:71)
at org.apache.camel.dsl.jbang.core.commands.CamelCommand.call(CamelCommand.java:37)
at picocli.CommandLine.executeUserObject(CommandLine.java:2045)
at picocli.CommandLine.access$1500(CommandLine.java:148)
at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2465)
at picocli.CommandLine$RunLast.handle(CommandLine.java:2457)
at picocli.CommandLine$RunLast.handle(CommandLine.java:2419)
at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2277)
at picocli.CommandLine$RunLast.execute(CommandLine.java:2421)
at picocli.CommandLine.execute(CommandLine.java:2174)
at org.apache.camel.dsl.jbang.core.commands.CamelJBangMain.run(CamelJBangMain.java:196)
at org.apache.camel.dsl.jbang.core.commands.CamelJBangMain.run(CamelJBangMain.java:72)
at main.CamelJBang.main(CamelJBang.java:36)

It looks like all of the rest routers has the same routId "test".

Environment

  • Red Hat Build of Apache Camel
    • 4.8

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content