Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I monitor a queue for when messages arrive?

Tags:

c#

.net

msmq

I'm looking for the equivalent of FileSystemWatcher for a specific MSMQ queue. Does something like that exist or do I need to roll my own?

Thanks!

like image 914
Micah Avatar asked Jan 30 '26 05:01

Micah


1 Answers

Isn't that basically what MQReceiveMessage does? My apologies for referencing the C docs, but all of this functionality should be available to .NET. Essentially you can use this function to peek at messages in the queue:

When reading messages, you can either peek at (not removing them) or retrieve the messages (removing them) in the queue.

And you can use it to block until a message is ready:

Processing is blocked in the applicable thread until a message is found in the queue (this is the default setting).

Apparently you can also use this function to receive messages asynchronously, in which case it would operate much like the FileSystemWatcher.

like image 104
Justin Ethier Avatar answered Jan 31 '26 19:01

Justin Ethier