Reputation: 643
I'm playing around with Camel, and as a simple testcase, I want to add an header to the incoming message and store it in a JMS queue (activemq). This is the code using the REST dsl:
rest("/query-set")
.id("queryset-route")
.get("{id}")
.route()
.process((exchange) -> {
exchange.getIn().setHeader("myHeader", constant(UUID.randomUUID()));
})
.setHeader(Exchange.HTTP_RESPONSE_CODE, constant(200))
.endParent()
.marshal().json(JsonLibrary.Jackson)
.to("jms:queue:querysetRequests?exchangePattern=InOnly");
Now when I do a GET with HTTPie (httpie.org):
http -a admin:admin GET http://localhost:8080/camel/query-set/someId?key=value 'Foo:bar'
and inspect the message in the queue, I notice the following:
BUT, my custom 'myHeader' with the random UUID as value is NOT present in as a JMS property.
What am I doing wrong?
Upvotes: 2
Views: 3072
Reputation: 55750
You are using a Processor
to set the header, and therefore you should just set the header value as-is. You should not use constant, eg
exchange.getIn().setHeader("myHeader", UUID.randomUUID());
as its just plain regular Java code.
And mind that JMS spec forbids certain types in JMS properties (aka Camel headers). There is some details at: http://camel.apache.org/jms
Upvotes: 1