简体   繁体   English

从MSMQ删除消息

[英]Remove messages from MSMQ

I have program which reads MSMQ using GetAllMessages but it does not remove messages from Queue so I have following code; 我有使用GetAllMessages读取MSMQ程序,但是它没有从Queue中删除消息,因此我有以下代码; which keep getting same messages. 不断收到相同的消息。 I do not want to process same message again and again. 我不想一次又一次地处理相同的消息。 How can I make sure that MSMQ deletes those already received messages or atleast I don't receive it ? 如何确保MSMQ删除那些已经收到的消息,或者至少不删除它?

while()
{
    Messages[] receivedMessage = queue.GetAllMessages()

    foreach(Message msg in receivedMessage)
    {
        ... Processing
    }
}

GetAllMessages() gives you a copy of the messages in the queue, but doesn't delete them. GetAllMessages()为您提供队列中消息的副本,但不会删除它们。

Use any of the Receive methods to receive and remove the messages from a queue 使用任何一种Receive方法来接收和从队列中删除消息

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM