MSMQ查询特定消息 [英] MSMQ querying for a specific message
问题描述
我有一个有关MSMQ的问题... 我设计了这样的异步架构:
I have a questing regarding MSMQ... I designed an async arhitecture like this:
客户端-> WCF服务(托管在WinService中)-> MSMQ
CLient - > WCF Service (hosted in WinService) -> MSMQ
因此,基本上,WCF服务接收请求,对其进行处理,将其添加到INPUT队列中并返回GUID.相同的WCF服务(通过侦听器)从队列中获取第一条消息(做一些事情...),然后将其放回到另一个队列中(输出).
so basically the WCF service takes the requests, processes them, adds them to an INPUT queue and returns a GUID. The same WCF service (through a listener) takes first message from queue (does some stuff...) and then it puts it back into another queue (OUTPUT).
问题是当客户端请求时如何从OUTPUT队列中检索结果...因为MSMQ不允许随机访问其消息,唯一的解决方案是遍历所有消息并将其推回直到找到我需要的确切对象为止.由于客户端施加的某些限制,我不想将DB用于此OUTPUT队列.
The problem is how can I retrieve the result from the OUTPUT queue when a client requests it... because MSMQ does not allow random access to it's messages and the only solution would be to iterate through all messages and push them back in until I find the exact one I need. I do not want to use DB for this OUTPUT queue, because of some limitations imposed by the client...
推荐答案
您可以使用
var mq = new MessageQueue(outputQueueName);
mq.PeekById(yourId);
按ID接收
mq.ReceiveById(yourId);
这篇关于MSMQ查询特定消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!