Hello,

first of all: This is my very first mail in this mailing list, and I am still 
learning the potential of Camel, so please give me any advise if I can make 
better 🙂

Summary:
I want to manage routes at runtime, and for this it is essential that I can 
identify a rule by its ID so that I am able to modify or remove it. I choosed 
YAML as my preferred DSL, but it seems that the ID attribute is not regarded 
and the route still gets its generic name instead. This seems like a bug for 
me, as with XML, the ID is used as expected. So before I fill in a bug report I 
ask (as requested) here if I am doing anything wrong or if you think that this 
is really a bug.

Test case:
A very simple Spring-Boot/Camel project:

pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0";
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd";>
    <modelVersion>4.0.0</modelVersion>

    <groupId>my.camel.testing</groupId>
    <artifactId>camle-testing</artifactId>
    <version>1.0-SNAPSHOT</version>

    <properties>
        <maven.compiler.source>17</maven.compiler.source>
        <maven.compiler.target>17</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

        <camel.version>4.0.1</camel.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.apache.camel.springboot</groupId>
            <artifactId>camel-spring-boot</artifactId>
            <version>${camel.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.camel.springboot</groupId>
            <artifactId>camel-spring-boot-starter</artifactId>
            <version>${camel.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-xml-io</artifactId>
            <version>${camel.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-xml-io-dsl</artifactId>
            <version>${camel.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-yaml-dsl</artifactId>
            <version>${camel.version}</version>
        </dependency>
    </dependencies>
</project>

Application.java:
@SpringBootApplication
public class Application {
    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }
}

Routes (placed in $PROJECT_HOME/camel/, autodetected by 
camel-spring-boot-starter):
myroute1.xml:
<routes xmlns="http://camel.apache.org/schema/spring";>
    <route id="myRoute1">
        <from uri="timer:tick"/>
        <setBody>
            <constant>Hello Camel!</constant>
        </setBody>
        <to uri="log:info1"/>
    </route>
</routes>

myroute2.yaml:
- from:
    id: myRoute2
    uri: timer:tick
    steps:
    - setBody:
        constant: Hello Camel!
    - to:
        uri: log:info2

I understand that both routes should be doing the same thing and the only 
difference is the ID.

When I start the application, the log shows this:
...
023-10-19T10:41:34.142+02:00  INFO 17160 --- [           main] 
o.a.c.impl.engine.AbstractCamelContext   : Routes startup (started:2)
2023-10-19T10:41:34.142+02:00  INFO 17160 --- [           main] 
o.a.c.impl.engine.AbstractCamelContext   :     Started myRoute1 (timer://tick)
2023-10-19T10:41:34.142+02:00  INFO 17160 --- [           main] 
o.a.c.impl.engine.AbstractCamelContext   :     Started route1 (timer://tick)
2023-10-19T10:41:34.142+02:00  INFO 17160 --- [           main] 
o.a.c.impl.engine.AbstractCamelContext   : Apache Camel 4.0.1 (camel-1) started 
in 15ms (build:0ms init:0ms start:15ms)
...

Note that the XML route was loaded using the correct ID (myRoute1), but the 
YAML is using a generic ID (route1). I would expect that the output is:
Routes startup (started:2)
    Started myRoute1 (timer://tick)
    Started myRoute2 (timer://tick)
Apache Camel 4.0.1 (camel-1) started in ...

Tested and verified with Camel v4.0.1 and v4.1.0

So, it seems like a bug in the YAML route builder. What do you think?

Thank you & kind regards,
Steffen

// added to skip company footer: 27948 //

Reply via email to