java 读取mq_java – 以字符串格式获取MQ messageId

MQ消息ID由24字节组成,不建议将其视为字符数据。若要转化为字符串,可使用HEX表示,例如IBM提供getHexString函数进行转换。消息ID包含产品标识和队列管理器特定的唯一字符串,确保互操作的队列管理器名称前12字符不同,防止时间回溯导致重复。应用需避免生成ID以避免与队列管理器生成的ID冲突。
摘要由CSDN通过智能技术生成

MQMD中的messageId表示为24个字节.如果您知道这些生成的平台,您可以通过将字节转换为生成它们的队列管理器的字符集中的字符来为它们的某些部分找到一些含义,但不建议依赖于传输的任何数据在messageID中作为字符数据,因为我看到IBM的语句类似于“MsgId is generated by MQ in an IBM proprietary format and it may change at any time.”

如果要将它们表示为字符串,则应将它们表示为表示24个字节的48个字符的HEX字符串.

下面是IBM在Technote中提供的示例函数getHexString,它将为您执行此转换.你会像这样使用它:

getHexString(theMessage.messageId)

public static String getHexString(byte[] b) throws Exception {

String result = "";

for (int i=0; i < b.length; i++) {

result += Integer.toString( ( b[i] & 0xff ) + 0x100, 16).substring( 1 );

}

return result;

}

A MsgId generated by the queue manager consists of a 4-byte product identifier (AMQ? or CSQ? in either ASCII or EBCDIC, where ? represents a blank character), followed by a product-specific implementation of a unique string. In IBM? MQ this contains the first 12 characters of the queue-manager name, and a value derived from the system clock. All queue managers that can intercommunicate must therefore have names that differ in the first 12 characters, in order to ensure that message identifiers are unique. The ability to generate a unique string also depends on the system clock not being changed backward. To eliminate the possibility of a message identifier generated by the queue manager duplicating one generated by the application, the application must avoid generating identifiers with initial characters in the range A through I in ASCII or EBCDIC (X’41’ through X’49’ and X’C1′ through X’C9′). However, the application is not prevented from generating identifiers with initial characters in these ranges.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值