Reputation: 2218
If there is an out of the box way to put a message into msmq with a defined expiration time out. under expiration I mean the following scenario:
message 1 published at 1:00 message 2 published at 1:02 message 3 published at 1:04
message 1 recieved at 1:00 and processed at 1:05
we shold process messages that are not older than 1 min so uder this requirement I wish that message 2 would disappeared from the queue
Questions:
Upvotes: 5
Views: 3034
Reputation: 3940
The System.Messaging.Message
class has a property for TimeToBeReceived
which will cause the message to be ignores (or posted to the bad letter queue) if it times out.
The only issue is that you have to be sure that the time on the client-side is synchronised with the time on the server side.
Upvotes: 0
Reputation: 684
The Message
class has a TimeToBeReceived
property (see MSDN). I think it should meet your requirement.
Also, it seems to me that your system cannot consume messages at the same pace as it produces them. It's difficult to tell without knowing further details about the system, but it may be worth exploring the possibility of consuming the messages in parallel (if you are not already doing that).
Upvotes: 6
Reputation: 10844
If you have access to the source code of both Producer/Consumer you could share a Queue but in memory and use LINQ to filter the message that are in the expected time frame and process them
Upvotes: 0