MessageListener,会不会获取并发消息

MessageListener, will it get concurrent messages

我正在使用 XMS 7.5 客户端访问 IBM MQ,想了解有关 MessageListener 的一件事。 当队列中存在多条消息时,

代码如下:

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)

一次向消费者发送一条消息,无论消费者是在调用 receive() 还是已设置消息侦听器来接收消息都没有关系。

如果是消息侦听器,MQ 将等待 OnMessage(在您的情况下是 ProcessNewMessage)方法到 return,然后再传送下一条合适的消息。