[每日一学]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有几种自动生成空项目 ...
随机推荐
- iOS SDK开发之 .a静态库
查看.framework静态库的生成及使用单击此处 注:这篇教程将只使用一小部分Objective-C代码,本文主要讲解从开始到应用的详细步骤.环境:xcode 9.2下面我们开始操作: 第一步:创建 ...
- c++实验10 图的应用实验
大体与上次实验相同,特点为图是邻接表存储结构 --博客后半部分有程序的所有代码-- 1.图邻接表存储结构表示及基本操作算法实现 所加载的库函数或常量定义及类的定义: #include "Se ...
- 阶段3 1.Mybatis_12.Mybatis注解开发_6 mybatis注解开发一对一的查询配置
新建Account实体类 生成getter和setter还有toString方法 先创建dao类 全局的配置,这里要改成package 创建多对一的关系 在查询的时候输出user这个对象的内容 建立查 ...
- 用JS实现移动的窗口
https://blog.csdn.net/iteye_21064/article/details/81496640 用JS实现移动的窗口 2007年09月06日 23:23:00 阅读数:3 很简单 ...
- es笔记---新建es索引
es对索引的一堆操作都是用restful api去进行的,参数时一堆json,一年前边查边写搞过一次,这回搞迁移,发现es都到6.0版本了,也变化了很多,写个小笔记记录一下. 创建一个es索引很简单, ...
- idea中创建maven格式的文件方法
其中新建的maven工程有时候不全或者出一些小问题导致新建类,或者其他文件时候找不到新建的快捷方式,下面就说一种快速设置
- expect替人进行交互
expect是一门独立于shell的语言 用expect 执行写好的脚本 #!/usr/bin/expectspawn ssh root@192.168.40.67 (spawn 是expect ...
- 2.nginx配置详细说明
Nginx配置详解 nginx概述 nginx是一款自由的.开源的.高性能的HTTP服务器和反向代理服务器:同时也是一个IMAP.POP3.SMTP代理服务器:nginx可以作为一个HTTP服务器进行 ...
- linux文件属性软链接
linux里的软链接 相当于windows系统中的快捷方式 软链接总结: 1.删除源文件,软链接文件依然存在,但是无法访问指向源文件路径内容. 2.失效时候一般是白字红底闪烁显示. test -> ...
- centos 7 中如何提取IP地址
ifconfig |grep -Eo "(([1-9)?[0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|1[0-9]{2}|2[0-4][0 ...