如何在c#中访问messagequeue的死信队列
我要查看死信队列的消息,然后把符合我的条件的消息重新发回原来队列中,代码如下:
///
/// 从死信队列恢复消息到队列
///
///
public static void ReloadFromDeadLetterQueue(string prefix)
{
prefix = string.Concat( ".private$\\ ", prefix);
MessageQueue deadLetterQueue = new MessageQueue(string.Concat(System.Environment.MachineName , @ "\Deadletter$ "));
MessageEnumerator e = deadLetterQueue.GetMessageEnumerator2();
Dictionary
MessageQueue queue;
while (e.MoveNext())
{
Message msg = e.Current;
string label = msg.Label;
if (label.StartsWith(prefix,StringComparison.OrdinalIgnoreCase))
{
if (messagequeues.ContainsKey(label))
{
queue = messagequeues[label];
}
else
{
queue = new MessageQueue(label);