[每日一学]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有几种自动生成空项目 ...
随机推荐
- 测试版和正式版微信小程序共享存储空间问题
一般习惯将变量存储在小程序的storage缓存中,然后用到的时候再去取.但是有一次我在做小程序相关内容的时候发现,对于苹果手机,测试版本小程序和正式版本小程序的缓存变量是相互通用的.
- webrtc相关概念
SDP Session Description Protocol Session Traversal Utilities for NAT(STUN)Traversal Using Relays aro ...
- 2 日志系统:一条sql更新语句是如何执行的?
2 日志系统:一条sql更新语句是如何执行的? 前面了解了一个查询语句的执行流程,并介绍了执行过程中涉及的处理模块,一条查询语句的执行过程一般是经过连接器.分析器.优化器.执行器等功能模块,最后达到e ...
- 终极Shell - Oh My Zsh
介绍 zsh: 与 bash 同为 shell 软件,适用于 linux 和 mac,mac 与百度开发机已自带. oh-my-zsh:zsh 的一个开源配置方案,即下即用,免去复杂的配置过程.配置后 ...
- 解决 WordPress 后台加载非常缓慢/打不开问题
在新版的 WordPress 中,为了后台的美观度,开发者在页面上加入了 Google Web 字体,这本来会让英文显示更加精美.我们只要移除 Google 在线字体即可恢复原来的速度.在你的主题的 ...
- unity监听粒子播放结束
需要在粒子上挂脚本 脚本添加代码 public void OnParticleSystemStopped() { Debug.Log("粒子停止"); } 这是个生命周期 粒子的 ...
- django中使用原生的orm
只有用的时候才能执行
- Maximum Depth of Binary Tree(二叉树最大深度)
来源:https://leetcode.com/problems/maximum-depth-of-binary-tree Given a binary tree, find its maximum ...
- 【嵌入式 Linux文件系统】如何使用NFS文件系统
(1)内核配置 取消选项 General setup-->Initial RAM filesystem and RAM disk (initramfs/initrd) support 进入Fil ...
- 【Linux 环境搭建】ubuntu 的samba配置
在/etc/samba/smb.conf的文件末尾增加下面的内容然后重启samba [home] comment = James Harden path = / browseable = yes wr ...