MessageListener, will it get concurrent messages

心已入冬 提交于 2019-12-11 03:37:49

问题


I'm using XMS 7.5 client to access the IBM MQ and wanted to know one thing about MessageListener. When there are multiple messages are present on the queue,

  • will the associated MessageListener method (i.e, ProcessNewMessage in the below code)called concurrently? OR
  • The messages will be dispatched to the MessageListener(i.e, ProcessNewMessage in the below code) method only at a time?

The code is something like below:

private XMSFactoryFactory xMSFactoryFactory;
private IConnectionFactory connectionFactory;
private IConnection connectionWMQ;
private ISession sessionWMQ;
private IDestination destination;
private IMessageConsumer messageConsumer;

xMSFactoryFactory= XMSFactoryFactory.GetInstance(XMSC.CT_WMQ);
connectionFactory = _xMSFactoryFactory.CreateConnectionFactory();
// Set queue manager name, set server names, channel, use
// XMSC.WMQ_CM_CLIENT as WMQ_CONNECTION_MODE

connectionWMQ = _connectionFactory.CreateConnection();
sessionWMQ = _connectionWMQ.CreateSession(true, AcknowledgeMode.SessionTransacted);
destination = sessionWMQ.CreateQueue(_queueSettings.QueueName);
messageConsumer = sessionWMQ.CreateConsumer(_destination);


messageConsumer.MessageListener = new MessageListener(ProcessNewMessage)

回答1:


Messages are delivered one at a time to consumer, it does not matter whether the consumer is calling receive() or has setup a message listener to receive messages.

In case of a message listener, MQ will wait for the OnMessage (in your case ProcessNewMessage) method to return before delivering the next suitable message.



来源:https://stackoverflow.com/questions/31813384/messagelistener-will-it-get-concurrent-messages

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!