當前位置:編程學習大全網 - 源碼下載 - java使用mq get api從mq中取數據怎樣觸發偵聽器連續取數據

java使用mq get api從mq中取數據怎樣觸發偵聽器連續取數據

{

//前面是準備管理器和隊列

MQQueueManager qMgr = new MQQueueManager(qManager);

int openOptions = MQConstants.MQOO_INPUT_AS_Q_DEF | MQConstants.MQOO_OUTPUT | MQConstants.MQOO_INQUIRE;

MQQueue queue = qMgr.accessQueue(qName, openOptions);

MQMessage rcvMessage = new MQMessage();

MQGetMessageOptions gmo = new MQGetMessageOptions();

gmo.options = gmo.options + MQConstants.MQGMO_WAIT + MQConstants.MQGMO_SYNCPOINT;

//讀取五秒超時,這裏目的是要有個讀取阻塞,和Socket編程類似。

gmo.waitInterval = 5000;

queue.get(rcvMessage, gmo);

//後面就是操作消息的部分略

}catch(Exception e){{

//前面是準備管理器和隊列

MQQueueManager qMgr = new MQQueueManager(qManager);

int openOptions = MQConstants.MQOO_INPUT_AS_Q_DEF | MQConstants.MQOO_OUTPUT | MQConstants.MQOO_INQUIRE;

MQQueue queue = qMgr.accessQueue(qName, openOptions);

MQMessage rcvMessage = new MQMessage();

MQGetMessageOptions gmo = new MQGetMessageOptions();

gmo.options = gmo.options + MQConstants.MQGMO_WAIT + MQConstants.MQGMO_SYNCPOINT;

//讀取五秒超時,這裏目的是要有個讀取阻塞,和Socket編程類似。

gmo.waitInterval = 5000;

queue.get(rcvMessage, gmo);

//後面就是操作消息的部分略

}catch(Exception e){

  • 上一篇:CRM軟件是維護客戶的有效幫手(CRM客戶維護)
  • 下一篇:雲在指尖是什麽?
  • copyright 2024編程學習大全網