[每日一学]apache camel|IBMWebsphere MQ header issue|MQRFH2 |MQSTR

Posted thinking different

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[每日一学]apache camel|IBMWebsphere MQ header issue|MQRFH2 |MQSTR相关的知识,希望对你有一定的参考价值。

 最近工作中,遇到一个很奇怪的问题:

现象:在camel开发中,通过 IBM Websphere MQ 给assasin 发送xml的message时,会多出<mcd>等这样的header出来

经查:


Being that Camel is using the JMS API to write a message to an MQ queue, MQ will use the RHQ2 header to store information about the message, etc. However, the reading app is a non-JMS app, which cannot read the RFH2 header. We would like to strip the header by utilizing the targetClient=MQ in our put call, but this isn‘t working. We tried targetClient=1 as well

原因是MQ自动加上这些header信息,而client端又无法识别,所以无法读取,出现异常。

解决方案:

在返回给client时,queue加上targetClient=1 ,告诉MQ驱动,不要发送header信息。

 


<route id="qname">
<from uri="amq:queue:qname" />
<transacted ref="requiredJta" />
<to uri="log:com.wellsfargo.1txc?showHeaders=true&amp;showBody=false&amp;multiline=false&amp;level=INFO"/>
<setHeader headerName="CamelJmsDestinationName"><constant>queue:///qname?targetClient=1</constant></setHeader>
<to uri="wmq:queue:qname" />
</route>

 

 

另一种方案:

用这个类配置在jmsConfiguartion类里:

 

https://jira.spring.io/secure/attachment/12688/IBMWebSphereMqDestinationResolver.java

其中代码:private int targetClient = JMSC.MQJMS_CLIENT_JMS_COMPLIANT;

要改成:   private int targetClient = JMSC.MQJMS_CLIENT_NONJMS_MQ;

 

以上是关于[每日一学]apache camel|IBMWebsphere MQ header issue|MQRFH2 |MQSTR的主要内容,如果未能解决你的问题,请参考以下文章

[每日一学]apache camel简介

[每日一学]apache camel|IBMWebsphere MQ header issue|MQRFH2 |MQSTR

每日一学|初识ActiveMQ消息中间件:企业信息化

每日一学

每日一学无

python内置函数每日一学 -- all()