[英]read message queue sent time from MSMQ Journal
我有一个启用了日志的MSMQ。 而且由于我们每天收到超过1000条消息,因此我想清除日志以仅保留最近2天的消息。 因此,我想阅读所有消息并对照“当前日期-2天”检查其SentTime属性。 但是此刻该程序将停止,因为不会提供Property SentTime。
错误:“ PropertyFilter设置不正确”
编码:
class Program {
static void Main(string[] args) {
string queueName = ".\\private$\\TEST;journal";
MessageQueue msgQueue = new MessageQueue(queueName);
Message[] messages = msgQueue.GetAllMessages();
try{
foreach (Message msg in messages){
//if(msg.SentTime < DateTime.Today.AddDays(-2)){
Console.WriteLine(msg.SentTime);
//}
}
}catch (Exception e){
Console.WriteLine(e.Message);
}
Console.Read();
}
}
为什么我无法访问该物业? 谁能帮忙? 非常感谢!
您可以使用
msgQueue.MessageReadPropertyFilter.SetAll();
并将所有过滤器属性设置为true。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.