Hello Pasquale ,
thank you very much! Setting the ID on the correct node let the route id having
the correct value now. It just works!
Maybe the example for YAML can be added to the FAQ at
https://camel.apache.org/manual/faq/how-do-i-name-my-routes.html, as this was
the source of my information!?
Best regards,
Steffen
Von: Pasquale Congiusti
Gesendet: Donnerstag, 19. Oktober 2023 13:10
An: users@camel.apache.org
Betreff: Re: YAML DSL route loader seems to ignore "id" attribute
Hello Steffen, and welcome to Apache Camel :)
The problem you're facing is related to the way you're coding the yaml as
the ID is a configuration you can override for the route (as you can also
see in the xml dsl). Try this one instead:
- route:
id: myRoute2
from:
uri: "timer:yaml"
parameters:
period: "1000"
steps:
- setBody:
simple: "Hello Camel from ${routeId}"
- log: "${body}"
$ camel run test.yaml
2023-10-19 13:07:17.876 INFO 439921 --- [ main]
org.apache.camel.main.MainSupport : Apache Camel (JBang) 4.0.0 is starting
2023-10-19 13:07:18.056 INFO 439921 --- [ main]
org.apache.camel.main.MainSupport : Using Java 17.0.7 with PID 439921.
Started by squake in /home/squake/workspace/fuse-camel-k-image
2023-10-19 13:07:18.830 INFO 439921 --- [ main]
mel.cli.connector.LocalCliConnector : Camel CLI enabled (local)
2023-10-19 13:07:18.909 INFO 439921 --- [ main]
el.impl.engine.AbstractCamelContext : Apache Camel 4.0.0 (test) is starting
2023-10-19 13:07:19.077 INFO 439921 --- [ main]
el.impl.engine.AbstractCamelContext : Routes startup (started:1)
2023-10-19 13:07:19.077 INFO 439921 --- [ main]
el.impl.engine.AbstractCamelContext : Started myRoute2 (timer://yaml)
2023-10-19 13:07:19.078 INFO 439921 --- [ main]
el.impl.engine.AbstractCamelContext : Apache Camel 4.0.0 (test) started in
168ms (build:0ms init:0ms start:168ms)
2023-10-19 13:07:20.101 INFO 439921 --- [ - timer://yaml] test.yaml:13
: Hello Camel from myRoute2
Cheers,
Pasquale.
On Thu, Oct 19, 2023 at 11:50 AM Steffen Salewski
wrote:
> 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:
>
> 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";>
> 4.0.0
>
> my.camel.testing
> camle-testing
> 1.0-SNAPSHOT
>
>
> 17
> 17
> UTF-8
>
> 4.0.1
>
>
>
>
> org.apache.camel.springboot
> camel-spring-boot
> ${camel.version}
>
>
> org.apache.camel.springboot
> camel-spring-boot-starter
> ${camel.version}
>
>
> org.apache.camel
> camel-xml-io
> ${camel.version}
>
>
> org.apache.camel
> camel-xml-io-dsl
> ${camel.version}
>
>
> org.apache.camel
> camel-yaml-dsl
> ${camel.version}
>
>
>
>
> 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:
> http://camel.apache.org/schema/spring";>
>
>
>
> Hello Camel!
>
>
>
>
>
> myroute2.yaml:
> - from:
> id: myRoute2
> uri: timer:tick
> steps:
> - setBody:
> constant: Hello Camel!
> - to:
> uri: log:info2
>
> I understand that both r