在MSMQ中通过任意标识符查找?

时间:2011-02-08 20:30:50

标签: msmq

2 个答案:

答案 0 :(得分:3)

如果您想使用在发送邮件之前创建的标识符,则可以使用messages Label property

在发送邮件之前无法访问message LookupID identifier

答案 1 :(得分:2)

为什么不使用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个字节,否则在分配时会抛出异常。

相关问题