问题
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
回答1:
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);
来源:https://stackoverflow.com/questions/31387820/how-to-access-activemq-jms-custom-header-property-from-camel-route