Apache Camel-IBM MQ集成 [英] Apache Camel - IBM MQ integration

查看:435
本文介绍了Apache Camel-IBM MQ集成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Apache骆驼(2.18版)项目,该项目通过IBM MQ客户端向我的合作伙伴的IBM MQ服务器发送文件.但是,我的伙伴将messageId用作文件名,因此,我们必须将特定的文件名设置为messageId.

I have a Apache camel (version 2.18) project that sends a file to my partner's IBM MQ server by IBM MQ client. However, my partner uses the messageId as the filename, thus, we have to set specific filename tomessageId.

我的问题是我们如何更改messageId?

My question is how we can change the messageId?

在将文件发送到IBM MQ服务器之前,我试图在JMS标头中添加JMS_IBM_MQMD_MsgIdMsgId或修改JMSMessageId,但是它不起作用. 有什么解决办法吗?

I tried to add JMS_IBM_MQMD_MsgId or MsgId or modify the JMSMessageId in JMS header before I send the file to the IBM MQ server, but it doesn't work. Do you have any solution?

这是spring文件中的代码.例如,在我们将JMS发送到我的伙伴的服务器之前.我们将以下键/值设置为JMS标头:

Here is the code in spring file. For example, before we send JMS to my partner's server. We set the below key/value to JMS header:

exchange.getIn().setHeader("JMS_IBM_MQMD_MsgId",MsgExtFileName().getBytes())
exchange.getIn().setHeader("JMS_IBM_Format", MQC.MQFMT_STRING)

推荐答案

IBM MQ v8知识中心在页面"

IBM MQ v8 Knowledge center documents how to set MQMD properties with IBM MQ Classes for JMS in the page "Reading and writing the message descriptor from an IBM MQ classes for JMS application"

必须将目标对象属性WMQ_MQMD_WRITE_ENABLED设置为true,MQMD属性的设置才能生效.然后,您可以使用消息的属性设置方法(例如setStringProperty)将值分配给MQMD字段.除StrucId和Version外,所有MQMD字段都公开.可以读取但不能写入BackoutCount.

You must set the Destination object property WMQ_MQMD_WRITE_ENABLED to true for the setting of MQMD properties to have any effect. You can then use the property setting methods of the message (for example setStringProperty) to assign values to the MQMD fields. All MQMD fields are exposed except StrucId and Version; BackoutCount can be read but not written to.

// Enable MQMD write
dest.setBooleanProperty(WMQConstants.WMQ_MQMD_WRITE_ENABLED, true);


IBM MQ v8知识中心页面" JMS消息对象属性"记录了可以设置的属性.


The IBM MQ v8 Knowledge center page "JMS message object properties" documents the properties that can set be set.

我是IBM MQ管理员,不熟悉Apache Camel,但我发现此StackOverflow帖子"简单表达语言"

I am a IBM MQ admin and not versed in Apache Camel, but I found this StackOverflow post "How to set ApplicationIdData using MQQueueConnectionFactory?" helpful along with the Apache Camel Documentation on "Simple Expression Language"

例如,可以将标头设置为布尔类型:

For example to set a header as a boolean type you can do:

.setHeader("cool", simple("true", Boolean.class))


根据上述信息,您只需要添加一行,即可设置JMS_IBM_MQMD_MsgId属性:


Based on the above information you just need to add one additional line to allow you to set the JMS_IBM_MQMD_MsgId peroperty:

exchange.getIn().setHeader("mdWriteEnabled", simple("true", Boolean.class))
exchange.getIn().setHeader("JMS_IBM_MQMD_MsgId",MsgExtFileName().getBytes())
exchange.getIn().setHeader("JMS_IBM_Format", MQC.MQFMT_STRING)

根据其他一些信息,请注意,我发现上面的setHeader可能不正确,您可能需要将其附加到队列目标URI的末尾:

NOTE based on some other info I found the setHeader above may not be correct and you may need to append it to the end of your Queue destination URI:

queue:///QueueName?mdWriteEnabled=true


请注意,IBM MQ MQMD中的messageId表示为24个字节.从平台传递到平台时,这不会转换,如果您使用的是正常的字母数字字符,即使字节数相同,从UTF-8到ASCII也不应该成为问题,但这是需要注意的.


Note that the messageId in the IBM MQ MQMD is represented as 24 bytes. This not not converted when passed from platform to platform, if you are using normal alpha numeric characters this should not be a problem even going from UTF-8 to ASCII since the byte values are the same, but it is something to be aware of.

有关messageId和字符集的更多信息,请参考以下两个StackOverflow答案:

For more information on messageId and character sets reference these two StackOverflow answers:

以字符串格式获取MQ messageId
不同平台上的MQ管理器上的CCSID

这篇关于Apache Camel-IBM MQ集成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆