【发布时间】:2019-03-30 00:41:49
【问题描述】:
我需要实现代码通过传递消息 id 从 IBM MQ 读取消息,我实现的程序将一次读取一条消息,但我的代码没有覆盖消息 id
public final void ReadMessage (String queueName) throws Exception {
int options = MQC.MQOOINQUIRE + MQC.MQOOFAILIFQUIESCING + MQC.MQOOINPUTSHARED;
System.out.printin ("start Creating the Queue....... )
MQQueue myQueue = this.mqManager.accessQueue(queueName, options) ;
MQMessage mgMessage = new MQMessage ( ) ;
MQGetMessageOptions gmo = new MQGetMessageOptions ( ) ;
gmo.options = MQC.MQGMO NO WAIT + MQC.MQGMO FAIL IF QUIESCING;
gmo.matchOptions = MQC.MQMO NONE;
gmo.waitlnterval = 15000;
try {
System.out.println("end of get Message from myqueue") ;
System.out.print In ("Message lenth" + mgMessage ( ) ) ;
mgMessage.characterSet = 300;
int length = mqMessage.getMessageLength( );
System. out ( of the message" + length) ;
System. out ( of the message" + mgMessage.readString(length)) ;
gmo.options = MQC.MQGMOWAIT | MQC.MQGMOBROWSENEXT;
}
catch (Exception e) {
}
}
此代码能够从队列中读取 1 条消息。但我需要传递消息 ID 并根据消息 ID 我需要阅读消息。
这个要求可行吗?如果是这样,请与我分享一些 IBM MQ 客户端的示例。
想知道如何在代码中传递消息 ID。
MQQueue myQueue = this.mqManager.accessQueue(queueName, options, MessageID) ;
谢谢
【问题讨论】: