setBody() call in a Camel route specified in Java DSL appears to have no effect
Issue
Consider this piece of Java code, which is intended to create a Camel route that generates a new message body on each invocation:
public class MyRouteBuilder extends RouteBuilder {
static int counter = 0;
public void configure() throws Exception {
from("direct:start")
.setBody (simple ("Hello World, " + counter++))
.to ("log://foo")
}
}
The purpose of the static variable counter
is just to keep a count of the number of invocations of the route, and provide a different message body on each one. In practice, the message body will be generated by some business logic.
It might be thought that each new invocation would result in a different message body, which in this example would follow a simple sequence like this:
Hello World 0
Hello World 1
Hello World 2
....
In practice, however, the message body is always Hello World 0
. Subsequent invocations of the route do not change the body.
Environment
- Red Hat JBoss Fuse
- 6.x
- 7.x
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.