English 中文(简体)
通过MSMQ中的任意标识符查找?
原标题:Lookup by an arbitrary identifier in MSMQ?
  • 时间:2011-02-08 20:30:49
  •  标签:
  • msmq

有没有一种方法可以在MSMQ中为消息分配一个标识符,然后稍后通过该标识符定位该消息(如果它仍在队列中)?

更具体地说,它需要是我控制下的唯一标识符,而不是MSMQ分配的标识符。

最佳回答
问题回答

为什么不使用CorrelationId?

var message = new Message(new Messageval(), new BinaryMessageFormatter());
message.CorrelationId = messageId;
queue.Send(message);

然后检索如下消息:

var resp = (Messageval) queue.ReceiveByCorrelationId(messageId,
                                                     TimeSpan.FromSeconds(30))
                             .Body;

CorrelationId需要正好由20个字节组成,否则分配时将引发异常。





相关问题
Private or Public MSMQ

We are using Queue for few of are WCF services. We are using NetMSMQ binding for the WCF services which use Private MSMQ. The system works OK on our QA environment. I am not sure of any real ...

how to archive msmq messages?

I have a bunch of messages in one of the queues from an old date. I would like to take a backup before purging them. Any thoughts? Schar

MSMQ Adding a delay on Messages

I have a Microsoft Message Queue that gets populated with messages. If there is a problem with the processing of the message, I would like to retry the message, I do not want to retry the message ...

clear Message Queue in C#

I use the Message Queue to send messages from one application to the other one (this has to work only on one particular machine) I create the queue like this on the receiver side: string ...

Getting the NServiceBus Distributor Sample To Work

I m trying to use the Distributor in the NServiceBus FullDuplex sample but I can t get it working. I ve been following the this guide Getting the NServiceBus Distributor Working, but it doesn t work. ...

热门标签