[英]IBM MQ XMS with .NET Core 3.1 - how fetch messages already existing on topic?
Im trying to consume messages from WMQ from my .NET Core worker service.我试图从我的 .NET Core 工作服务中使用来自 WMQ 的消息。 I get it to work if I start my service and then publish messages on queue, but my service ignores all already existing messages.
如果我启动我的服务然后在队列上发布消息,我就可以正常工作,但我的服务会忽略所有已经存在的消息。 I read about durable subscribers, but that does not seem to quite be what Im after.
我读过关于持久订阅者的文章,但这似乎并不是我所追求的。
currently using nuget : IBMXMSDotnetClient, 9.2.0.1当前使用 nuget:IBMXMSDotnetClient,9.2.0.1
code:代码:
var destinationName = _apexConsumerOptions.Destination;
var isTopic = destinationName.StartsWith("topic://");
destinationName = destinationName.Remove(0, 8);
_connectionWmq = CreateConnection();
_sessionWmq = _connectionWmq.CreateSession(false, AcknowledgeMode.ClientAcknowledge);
_destination = isTopic ? _sessionWmq.CreateTopic(destinationName) : _sessionWmq.CreateQueue(destinationName);
_consumer = _sessionWmq.CreateConsumer(_destination);
_connectionWmq.Start();
while (!stoppingToken.IsCancellationRequested)
{
// fetch message
var message = _consumer.Receive(_apexConsumerOptions.Timeout);
HandleMessage(message);
await Task.Delay(_apexConsumerOptions.MillisecondsBetweenSyncPolls, stoppingToken);
}
_connectionWmq.Close();
I'm trying to subscribe to topic, not queue.我正在尝试订阅主题,而不是队列。
I also have issues with MessageListener only activating on first message posted, but that seems to be known issue with 9.2.我也有 MessageListener 仅在发布的第一条消息时激活的问题,但这似乎是 9.2 的已知问题。
Ultimately it was a durable subscriber I was after, so implementing that solved my issue.最终它是我所追求的持久订阅者,因此实施它解决了我的问题。
link to docs @ ibm about durable subscribers : https://www.ibm.com/support/knowledgecenter/SSFKSJ_9.2.0/com.ibm.mq.dev.doc/xms_csub_dur.htm链接到关于持久订阅者的 ibm 文档: https : //www.ibm.com/support/knowledgecenter/SSFKSJ_9.2.0/com.ibm.mq.dev.doc/xms_csub_dur.htm
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.