在肯定确认消息为时,不发送MSMQ否定确认消息

时间:2015-08-25 23:20:24

标签: c# visual-studio msmq

嗨,我有这段代码,当邮件到达预定的队列时(邮件最终在队列中,而确认邮件在另一个队列中结束,表明邮件已到达目的地),它们可以正常工作。

由于某些原因,当消息未到达其队列时(确认消息永远不会发送到其队列),它无法按预期工作。

我一直在测试这个,只需删除常规消息要访问的私有队列,如果有任何帮助的话。

Message message = new Message();
message.TimeToReachQueue = TimeSpan.FromMilliseconds(m_timeToReachQueue);
message.AcknowledgeType =  AcknowledgeTypes.FullReachQueue;
// set admin queue for receiving (negative) acknowledgements of delivery                
message.AdministrationQueue = new MessageQueue(m_adminQueueName);
message.ResponseQueue = new MessageQueue(m_adminQueueName);

//This is just for populating the message body and label then finally sending it
message.Label = RenderLabel(loggingEvent);       
using (System.IO.MemoryStream stream = new System.IO.MemoryStream())
    {
        System.IO.StreamWriter writer = new System.IO.StreamWriter(stream, new System.Text.UTF8Encoding(false, true));
        base.RenderLoggingEvent(writer, loggingEvent);
        writer.Flush();
        stream.Position = 0;
        message.BodyStream = stream;

        m_queue.Send(message);
        m_queue.Close();
    }

0 个答案:

没有答案