Message processing in asp.net (MSMQ) II

Source: Internet
Author: User

In my last article, ASP. NET in message processing (MSMQ) a popular introduction to MSMQ, finally to send ordinary text messages and complex object messages for example, introduced the use of Message Queuing. Based on this, this article continues to introduce the relevant knowledge points of MSMQ, and finally through an example program to analyze the application of MSMQ in the actual project development.

Suggestion: If you are not familiar with MSMQ, please read the first part before you read this article: ASP. NET in the message processing (MSMQ) one.

First, the priority of message delivery

In MSMQ, messages are transmitted in a queue with priority, and here I introduce the use of precedence in the form of an instance, with a total of seven priorities, all encapsulated in the Messagepriority enumeration. Because this is just a program demo, not one of the list, with only the highest and normal two types, on Message Queuing for message transmission of the seven priorities you can refer to the messagepriority enumerated source code definition that I provided below.

So how do you specify the priority of a message when sending a message? The message object is encapsulated with a property priority, which accepts a value of an enumerated messagepriority type to set the priority of the messages transport. As follows:

1system.messaging.message message = new System.Messaging.Message ();
2message. Priority = Messagepriority.highest; Highest message priority

Let's take a look at a sample program that uses precedence in message transfer and learn more clearly through the sample program. Sample Program Interface:

According to the interface, provides the message name, message priority and message content three entries, previously said, here to facilitate the demonstration of the only use of highest and normal two types, when the click to send a message by whether or not to select priority to set the priority of the message, the code is as follows:

1private void Btnsend_click (object sender, EventArgs e)
2{
3//connection to the local private queue Myqueue
4 MessageQueue myqueue = NE W MessageQueue (". \\private$\\myQueue");
5 System.Messaging.Message message = new System.Messaging.Message ();
6 message. Label = Tbname.text;
7 message. BODY = Tbcontext.text;
8
9 if (cbpriority.checked)
{one message
. Priority = messagepriority.highest;
is
else
. Priority = Messagepriority.normal;
myqueue.send (message);
MessageBox.Show ("Send Message to queue successfully");
19}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.