By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,851 Members | 1,033 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,851 IT Pros & Developers. It's quick & easy.

Message Queue in C# : Priority

P: n/a
Hi,

I have a question on Microsoft Message Queue. How do I give higher priority
to messages and get it process before others. I will like to use the
mechanism supplied by the queue service rather than relying on reading all
the messages and ordering them. Below I have a simple send and receive.

System.Messaging.Message msg = new System.Messaging.Message();
msg.Body=myPayment;
MessageQueue msgQ =new MessageQueue(".\\Private$\\billpay");
msgQ.Send(msg);
msgQ.Formatter = new XmlMessageFormatter(arrTypes);
myPayment=((Payment)msgQ.Receive().Body);

Your assistants will be greatly
appreciated.

ThanksTiger
Nov 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
tiger,

You can set the Priority property of the message to a priority, but it's
not very granular.

The only way to really handle this is to read the messages from the
queue as they come in, and then process them in the order that you want.
MSMQ doesn't really guarantee order.

What you might want to do is store the ids of the messages as you send
them. On the server side, you would read the messages and store them, along
with their ids. Then, on the client, when you know you have sent the
messages, you send another message indicating which messages to process (and
possibly order).

Of course, this means that you will have to wait until all of those
messages come in to process.

This makes me think that your approach could be improved upon. Instead
of sending all of these messages which require specific ordering, why not
just send ONE message which has the tasks that need to be performed, and
have the server process that?

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"tiger" <aa*****@omega.uta.edu> wrote in message
news:uQ*************@tk2msftngp13.phx.gbl...
Hi,

I have a question on Microsoft Message Queue. How do I give higher
priority
to messages and get it process before others. I will like to use the
mechanism supplied by the queue service rather than relying on reading all
the messages and ordering them. Below I have a simple send and receive.

System.Messaging.Message msg = new System.Messaging.Message();
msg.Body=myPayment;
MessageQueue msgQ =new MessageQueue(".\\Private$\\billpay");
msgQ.Send(msg);
msgQ.Formatter = new XmlMessageFormatter(arrTypes);
myPayment=((Payment)msgQ.Receive().Body);

Your assistants will be greatly
appreciated.

ThanksTiger

Nov 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.