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

现象:在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

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的更多相关文章

  1. [每日一学]apache camel简介

    apache camel 是轻量级esb框架.如下是它的架构图: 它有几个比较重要的概念就是: 1.endpoint,所谓的endpoint,就是一种可以接收或发送数据的组件.可以支持多种协议,如jm ...

  2. [每日一学]apache camel|BDD方式开发apache camel|Groovy|Spock

    开发apache camel应用,最好的方式就是tdd,因为camel的每个组件都是相互独立并可测试的. 现在有很多好的测试框架,用groovy的Spock框架的BDD(行为测试驱动)是比较优秀和好用 ...

  3. [每日一学]apache camel|XSLT|SAXON

    最近工作中,用到xslt文件来描述和配置xml文件的转换规则和业务逻辑,开始用jdk自带的TransformerFactory, 有严重的性能问题 后来用Saxon 的com.saxonica.con ...

  4. Apache Camel之FTP组件学习

    写在最前面 哎,最近提了离职,手头的活也基本上清理的差不多了.想着这个把月可以舒服的晃悠晃悠的离开,但是运维的小伙伴总是不架势,走之前还是提了个新需求. 先说下需求吧,我们的系统概括的讲就是一个接口系 ...

  5. Apache Camel

    Apache Camel 1 import org.apache.camel.CamelContext; import org.apache.camel.builder.RouteBuilder; i ...

  6. spring boot + apache camel 传输文件

    一 sftp搭建略 这里简单说一下为什么使用sftp.ftp和sftp各有优点,差别并不是太大.sftp安全性好,性能比ftp低.ftp对于java来说并不复杂,效率也高.之所以使用sftp主要是可以 ...

  7. Apache Camel继承Spring Boot 实现文件远程复制和转移

    pom.xml <dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-f ...

  8. Apache Camel,Spring Boot 实现文件复制,转移 (转)

    基本框架 Apache Camel Spring Boot Maven 开发过程 1.新建一个POM(quickstart)项目,在POM文件中添加Camel和Spring Boot的依赖 <p ...

  9. Apache Camel 与 Spring Boot 集成,通过FTP定时采集、处理文件 (转)

    1.概要: 本项目主要是通过在Spring平台上配置Camel.FTP,实现定时从FTP服务器下载文件到本地.解析文件.存入数据库等功能. 2.搭建空项目: Spring Boot有几种自动生成空项目 ...

随机推荐

  1. java 重写和重载的区别

    重写:重写是子类的方法覆盖父类的方法,有两个重要特点 1.子类方法名和参数类型.个数必须和父类一样. 2.如果有返回值,则返回值类型也必须和父类一样. //父类 public class Bird() ...

  2. 13 oracle数据库坏块-逻辑坏块(模拟/修复)

    13 oracle数据库坏块-逻辑坏块 逻辑数据坏块的场景1)oracle bug也可能导致逻辑坏块的产生. 特别是parallel dml. 例如:Bug 5621677 Logical corru ...

  3. Intellij Idea使用教程汇总篇

    Java编程强大的工具IDEA使用教程及一些快捷键收藏如下: https://blog.csdn.net/fanrenxiang/article/details/80503490

  4. maven spark Scala idea搭建maven项目的 pom.xml文件配置

    1.pom.xml文件配置,直接上代码. <?xml version="1.0" encoding="UTF-8"?> <project xm ...

  5. 【Linux开发】./configure,make,make install的作用

    这些都是典型的使用GNU的AUTOCONF和AUTOMAKE产生的程序的安装步骤. ./configure是用来检测你的安装平台的目标特征的.比如它会检测你是不是有CC或GCC,并不是需要CC或GCC ...

  6. 【Linux开发】Linux V4L2驱动架构解析与开发导引

    Linux V4L2驱动架构解析与开发导引 Andrew按:众所周知,linux中可以采用灵活的多层次的驱动架构来对接口进行统一与抽象,最低层次的驱动总是直接面向硬件的,而最高层次的驱动在linux中 ...

  7. 20191127 Spring Boot官方文档学习(4.13)

    4.13.Messaging Spring框架为与消息传递系统集成提供了广泛的支持,从使用JmsTemplate简化JMS API到完整的异步接收消息的基础结构.Spring AMQP为高级消息队列协 ...

  8. 20191127 Spring Boot官方文档学习(5)

    5.Spring Boot Actuator:可投入生产的功能 Spring Boot包含许多其他功能,可帮助您在将应用程序投入生产时监控和管理您的应用程序.您可以选择使用HTTP端点或JMX管理和监 ...

  9. spring -boot定时任务 quartz 基于 JobDetailFactoryBean实现

    这个有点小问题 尚未解决  后期优化 基于 JobDetailFactoryBean实现 依赖包 <dependencies> <dependency> <groupId ...

  10. linux rz上传-sz下载

    yum install lrzsz -y rz     上传文件    不能传目录 如果要传目录需要打包成文件再上传 需要往哪里传东西,先进入哪个目录 rz -y   上传覆盖 sz -y 文件名  ...