如何访问ActiveMQ的JMS自定义页眉财产;骆驼航线 [英] how to access activemq jms custom header property; from camel route

查看:249
本文介绍了如何访问ActiveMQ的JMS自定义页眉财产;骆驼航线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请参阅此<一个href=\"http://stackoverflow.com/questions/31303891/how-to-set-jms-message-custom-header-using-xpath-in-camel-route\">question第一。如何访问,从队列2这条道路建设者方法或类以外的自定义标题属性值?

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

我使用类似如下图所示。我不觉得在consumerTemplate API的方法来获取自定义标题属性。

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

推荐答案

您需要接受它作为一个兑换将所有数据

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);

这篇关于如何访问ActiveMQ的JMS自定义页眉财产;骆驼航线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆