I have an MSMQ with an enabled Journal. 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. Therfore I want to read all messages and check their SentTime property against the "current date - 2 days". But at the moment the program will stop as the Property SentTime wont be provided.
Error: "PropertyFilter isn't set correctly"
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With