[每日一学]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&showBody=false&multiline=false&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
example code :
==============================================================================
package org.springframework.jms.support.destination; import javax.jms.Destination;
import javax.jms.JMSException;
import javax.jms.Session; import com.ibm.mq.jms.JMSC;
import com.ibm.mq.jms.MQDestination; /**
*
* Dynamic destination resolver which can set some IBM WebSphere MQ
* specific properties.
*
* @author <a href="mailto:david@davidkarlsen.com">David J. M. Karlsen</a>
* @see com.ibm.mq.jms.JMSC
* @see DestinationResolver
* @see DynamicDestinationResolver
*
*/
public class IBMWebSphereMqDestinationResolver
extends DynamicDestinationResolver
implements DestinationResolver
{
private int ccsid = 819;
private int encoding = JMSC.MQJMS_ENCODING_NATIVE;
private int failIfQuiesce = JMSC.MQJMS_FIQ_YES;
private int targetClient = JMSC.MQJMS_CLIENT_JMS_COMPLIANT; /**
* @param ccsid
* Character set for automatic conversion of message payload.
* <p>
* Defaults to com.ibm.mq.jms.JMSC.MQJMS_FIQ_YES
*/
public void setCcsid( int ccsid )
{
this.ccsid = ccsid;
}
/**
* @param encoding
* Encoding for message payload.
* <p>
* Defaults to com.ibm.mq.jms.JMSC.MQJMS_ENCODING_NATIVE
*/
public void setEncoding( int encoding )
{
this.encoding = encoding;
}
/**
* @param failIfQuiesce
*
* Control graceful exits when queue manager is quesing.
* <p>
* Defaults to com.ibm.mq.jms.JMSC.MQJMS_FIQ_YES
*/
public void setFailIfQuiesce( int failIfQuiesce )
{
this.failIfQuiesce = failIfQuiesce;
}
/**
* @param targetClient
* Control target client type (JMS compliant or not).
* <p>
* Defaults to com.ibm.mq.jms.JMSC.MQJMS_CLIENT_JMS_COMPLIANT
*/
public void setTargetClient( int targetClient )
{
this.targetClient = targetClient;
}
protected int getCcsid()
{
return ccsid;
}
protected int getEncoding()
{
return encoding;
}
protected int getFailIfQuiesce()
{
return failIfQuiesce;
}
protected int getTargetClient()
{
return targetClient;
} /**
* {@inheritDoc}
* @see DestinationResolver#resolveDestinationName(Session, String, boolean)
*/
public Destination resolveDestinationName( Session session,
String destinationName,
boolean isPubSubDomain )
throws JMSException
{ Destination destination = super.resolveDestinationName( session, destinationName, isPubSubDomain );
if ( destination instanceof MQDestination )
{
MQDestination mqDestination = (MQDestination) destination;
mqDestination.setCCSID( getCcsid() );
mqDestination.setEncoding( getEncoding() );
mqDestination.setFailIfQuiesce( getFailIfQuiesce() );
mqDestination.setTargetClient( getTargetClient() );
} return destination;
} }
===============================================================================================================
其中代码: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 是轻量级esb框架.如下是它的架构图: 它有几个比较重要的概念就是: 1.endpoint,所谓的endpoint,就是一种可以接收或发送数据的组件.可以支持多种协议,如jm ...
- [每日一学]apache camel|BDD方式开发apache camel|Groovy|Spock
开发apache camel应用,最好的方式就是tdd,因为camel的每个组件都是相互独立并可测试的. 现在有很多好的测试框架,用groovy的Spock框架的BDD(行为测试驱动)是比较优秀和好用 ...
- [每日一学]apache camel|XSLT|SAXON
最近工作中,用到xslt文件来描述和配置xml文件的转换规则和业务逻辑,开始用jdk自带的TransformerFactory, 有严重的性能问题 后来用Saxon 的com.saxonica.con ...
- Apache Camel之FTP组件学习
写在最前面 哎,最近提了离职,手头的活也基本上清理的差不多了.想着这个把月可以舒服的晃悠晃悠的离开,但是运维的小伙伴总是不架势,走之前还是提了个新需求. 先说下需求吧,我们的系统概括的讲就是一个接口系 ...
- Apache Camel
Apache Camel 1 import org.apache.camel.CamelContext; import org.apache.camel.builder.RouteBuilder; i ...
- spring boot + apache camel 传输文件
一 sftp搭建略 这里简单说一下为什么使用sftp.ftp和sftp各有优点,差别并不是太大.sftp安全性好,性能比ftp低.ftp对于java来说并不复杂,效率也高.之所以使用sftp主要是可以 ...
- Apache Camel继承Spring Boot 实现文件远程复制和转移
pom.xml <dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-f ...
- Apache Camel,Spring Boot 实现文件复制,转移 (转)
基本框架 Apache Camel Spring Boot Maven 开发过程 1.新建一个POM(quickstart)项目,在POM文件中添加Camel和Spring Boot的依赖 <p ...
- Apache Camel 与 Spring Boot 集成,通过FTP定时采集、处理文件 (转)
1.概要: 本项目主要是通过在Spring平台上配置Camel.FTP,实现定时从FTP服务器下载文件到本地.解析文件.存入数据库等功能. 2.搭建空项目: Spring Boot有几种自动生成空项目 ...
随机推荐
- Android MQTT的发布与订阅
一.MQTT介绍 链接1(菜鸟教程):https://www.runoob.com/w3cnote/mqtt-intro.html 连接2(MQTT中文网):http://mqtt.p2hp.com/ ...
- Oracle JET mobile cordove navigator.app对象
在使用 Oracle JET 开发 webapp 时,会使用到 ojrouter ,ojrouter 默认含有历史记录推送功能.在调试 Android 时会发现返回键总是返回到上一次浏览记录(App ...
- Detectron系统实现了最先进的物体检测算法https://github.com/facebookresearch/Detectron
,包括Mask R-CNN. 它是用Python编写的,支持Caffe2深度学习框架. 不久前,FAIR才开源了语音识别的工具wav2letter,戳这里看大数据文摘介绍<快讯 | Facebo ...
- office toolkit怎么用(以激活office professional 2013为例)
第一步:双击打开office toolkit工具,并选择office按钮(激活windows10选择windows按钮) 第二步:选择相应的office版本,我电脑安装的是Microsoft Offi ...
- CSS-W3School:CSS table-layout 属性
ylbtech-CSS-W3School:CSS table-layout 属性 1.返回顶部 1. CSS table-layout 属性 CSS 参考手册 实例 设置表格布局算法: table { ...
- 浅谈call apply bind的区别
这三个方法的用法非常相似,将函数绑定到上下文中,即用来改变函数中this的指向.举个例子: var zlw = { name: "zlw", sayHello: function ...
- [VBA]获得工作表名称
sub 获得工作表名称() Dim i As Integer For i = 1 To Worksheets.Count Cells(i, 2) = Worksheets(i).Name Next E ...
- 将html转化为canvas图片(清晰度高)的方法
var copyDom = document.querySelector('.fenxiang1'); var width = copyDom.offsetWidth;//dom宽 var heigh ...
- 大sd卡 裂开了,写保护掉了。重新装好后,被写保护的解决办:
大sd卡 裂开了,写保护掉了.重新装好后,被写保护的解决办: 1.用烙铁把写保护附近的塑料往外顶一点点,就ok 别太热,也别劲太大.容易过,不能破坏原来的部分. 解决问题. 总结: 写保护,就是检 ...
- 源特定组播(SSM:Source Specific Multicast)
源特定组播(SSM:Source Specific Multicast)是一种区别于传统组播的新的业务模型,它使用组播组地址和组播源地址同时来标识一个组播会话,而不是向传统的组播服务那样只使用组播组地 ...