我已經關於messageId
在WebSphere MQ兩個一般性問題:的WebSphere MQ消息
1)此字段可用於實現在一個隊列中同步通信? 例如,在下面的源代碼:
MQMessage hello_world = new MQMessage();
hello_world.writeUTF("Hello World!");
MQPutMessageOptions pmo = new MQPutMessageOptions();
system_default_local_queue.put(hello_world,pmo);
MQMessage retrievedMessage = new MQMessage();
retrievedMessage.messageId = hello_world.messageId;
MQGetMessageOptions gmo = new MQGetMessageOptions();
system_default_local_queue.get(retrievedMessage, gmo);
檢索到的消息將是hello_world
消息,並且僅此消息將被檢索離開所有的其它消息隊列中,即使有超過老化的精確響應這個?
2)如果是這樣的話可以這樣用兩個隊列做了什麼? 例子: 客戶端:
MQMessage hello_world = new MQMessage();
hello_world.writeUTF("Hello World!");
MQPutMessageOptions pmo = new MQPutMessageOptions();
input_queue.put(hello_world,pmo);
MQMessage retrievedMessage = new MQMessage();
retrievedMessage.messageId = hello_world.messageId;
MQGetMessageOptions gmo = new MQGetMessageOptions();
output_queue.get(retrievedMessage, gmo);
服務器端:
while(true){
MQMessage inMessage= new MQMessage();
input_queue.get(mqMessage ,gmo);
//actions to get the contents of the inMessage and create proper response
MQMessage outMessage= new MQMessage();
//write the proper response to outMessage
outMessage.messageId = inMessage.messageId;
output_queue.put(outMessage, pmo);
}
Mq_queue被指定爲默認異步,在一側是生產者 - >信道 - >消費者,如果創建了兩個分離的通道put_channel和get_channel,但message_flow仍保持不變第二例子是舒適用於數據流 - - >異步 – mKorbel 2012-01-16 22:53:16