...
Code Block |
---|
from("direct:example").setBody(spel("Hello #{request.body}! What a beautiful #{request.headers['dayOrNight']}")).to("mock:result"); |
In the route above, notice spel is a static method which we need to import from org.apache.camel.language.spel.SpelExpression.spel
, as we use spel as an Expression passed in as a parameter to the setBody
method. Though if we use the fluent API we can do this instead:
Code Block |
---|
from("direct:example").setBody().spel("Hello #{request.body}! What a beautiful #{request.headers['dayOrNight']}").to("mock:result");
|
Notice we now use the spel
method from the setBody()
method. And this does not require us to static import the spel method from org.apache.camel.language.spel.SpelExpression.spel
.
And sent a message with the string "World" in the body, and a header "dayOrNight" with value "day":
...