Groups | Blog | Home
all groups > dotnet academic > october 2005 >

dotnet academic : Message queue in C#: Priority issue


tiger
10/3/2005 12:17:43 AM
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

Richard T. Edwards
10/3/2005 6:12:44 AM
Message priority effects how MSMQ handles the message while it is in route,
as well as where the message is placed in the queue.

Higher priority messages are given preference during routing and inserted
toward the front of the queue. Messages with the same priority are placed in
the queue according to their arrival time.

MSMQ sets the priority level of transactional messages to 0:
PROPID_M_PRIORITY is ignored by the transaction.

To set the priority of a message, specify PROPID_M_PRIORITY in the
MQMSGPROPS structure and call MQSendMessage.

To determine the priority of a message in the queue, specify
PROPID_M_PRIORITY in the MQMSGPROPS structure. Then call MQReceiveMessage
and examine its returned value.



hth.

[quoted text, click to view]

AddThis Social Bookmark Button