how to set id of camel processor or other route ingredients

apache-camel

Solution

If using xml then use the id attribute.

<to id="foo" uri="seda:foo"/>

And if using java code, then use `.id`

.to("seda:bar").id("foo");

And one special is to set the id of the route, which you must use `.routeId`

from("xxx").routeId("id of the route")
   .to("xxx")

So your example should be

from("some:where").process(myProcessor).id("theIdOfTheProcessorYouWant").to(no:where)

Problem

Camel automatically generates id for processors and other stuff (processor1..processor25). Is there a way to set this name? We need to identify certain processors via jmx to get telemetry data. The names I want to set are given via properties - they are known on start time. So I need to set them when route is defined or within the processor (name is given via processors constructor, the string is also used for processing). Update Example: for a route `from("some:where").process(myProcessor).to(no:where)` i need to set the id of myProcessor. I need "ExchangesTotal" and other stuff from certain processors I need a solution in Java DSL.

Original source