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

≯℡__Kan透↙ 提交于 2019-12-25 04:42:45

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!