[每日一学]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有几种自动生成空项目 ...
随机推荐
- from sklearn import datasets运行错误:ImportError: DLL load failed: 找不到指定的程序------解决办法
在运行集成学习的多数投票分类代码时,出现错误 from sklearn import datasets from sklearn.model_selection import cross_val_sc ...
- 1443:【例题4】Addition Chains
1443:[例题4]Addition Chains 题解 注释在代码里 注意优化搜索顺序以及最优化剪枝 代码 #include<iostream> #include<cstdio&g ...
- Jmeter之循环控制器
在使用Jmeter测试时,部分接口需要循环执行多次,这时候就可以使用循环控制器去控制执行. 循环控制器如下图: 说明 : (1.名称:标识,建议明确此循环控制器的使用的作用是什么(如:登录循环控制) ...
- 6.824 Lab 3: Fault-tolerant Key/Value Service 3B
Part B: Key/value service with log compaction Do a git pull to get the latest lab software. As thing ...
- python string_1
quote :http://www.runoob.com/python/python-strings.html #coding:utf-8 s1="http://www.jnshu.com/ ...
- Visdom可视化
Visdom是基于Pytorch的可视化工具 安装方式: pip install visdom 因为Visdom本质上是一个Web服务器,把数据渲染到网页上,因此首先需要运行这个 服务器,如下: py ...
- python pandas 自动生成批量测试数据插入数据库 mysql
1.python连接数据库游标 # coding:utf-8 from sqlalchemy import create_engine class connet_databases: def __in ...
- netcat命令用法
1,端口扫描nc -z -v -n 172.31.100.7 21-25 2,聊天Server:nc -l 1567Client:nc 172.31.100.7 1567 3,文件传输Server:n ...
- django中使用原生的orm
只有用的时候才能执行
- 创建React脚手架
node版本10.14.2 下载地址 如果是其版本的话会出错 css-loader 会不兼容 主要是8.x的版本不兼容 npm install -g create-react-app 全局安装 cre ...