[英]read message queue sent time from MSMQ Journal
I have an MSMQ with an enabled Journal. 我有一个启用了日志的MSMQ。 And due to the fact that we receive more than 1000 messages per day I want to clear the Journal to keep only the messages from last 2 days.
而且由于我们每天收到超过1000条消息,因此我想清除日志以仅保留最近2天的消息。 Therfore I want to read all messages and check their SentTime property against the "current date - 2 days".
因此,我想阅读所有消息并对照“当前日期-2天”检查其SentTime属性。 But at the moment the program will stop as the Property SentTime wont be provided.
但是此刻该程序将停止,因为不会提供Property SentTime。
Error: "PropertyFilter isn't set correctly" 错误:“ PropertyFilter设置不正确”
The code: 编码:
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();
}
}
Why do I have no access to the Property? 为什么我无法访问该物业? Who can help?
谁能帮忙? Thanks a lot!
非常感谢!
You can use 您可以使用
msgQueue.MessageReadPropertyFilter.SetAll();
and it will set all filter properties to true. 并将所有过滤器属性设置为true。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.