Nomad
Nomad

Reputation: 781

how to access activemq jms custom header property; from camel route

Please see this question first. How can I access that custom header property value from "queue2"?outside of that route builder method or class.

I am using something like shown below. I dont find any methods in consumerTemplate API to get custom header properties.

ConsumerTemplate consumerTemplate = camelContext.createConsumerTemplate();
textMessage = consumerTemplate.receiveBody("activemq:queue2",10000,String.class);

that question is to set header using camel route. but this question about how to access that custom header outside of that class using queue name

Upvotes: 0

Views: 3606

Answers (1)

Claus Ibsen
Claus Ibsen

Reputation: 55750

You need to receive it as an Exchange to have all the data

ConsumerTemplate consumerTemplate = camelContext.createConsumerTemplate();
Exchange exchange = consumerTemplate.receive("activemq:queue2",10000);

String data = exchange.getIn().getBody(String.class);
String orderNumber = exchange.getIn().getHeader("orderNumber", String.class);

Upvotes: 2

Related Questions