The previous time study WCF contacted MSMQ, so seriously learned a bit, here is my notes.
I understand that MSMQ
MSMQ can be seen as a data storage device, just like a database, except that the data stores a single record, and MSMQ stores a single message (MESSSGE). The message can be understood as a data container, as we'll talk about later. An important application scenario for MSMQ is offline information interaction, for example, we are sending a message to a friend, and when a friend does not log in to the mailbox, this time our mail can be sent to the mail server MSMQ queue, when a friend log in the mailbox, the system in the MSMQ queue from the server to remove the U pieces. Of course, the purpose of MSMQ is far more than that, for example, to act as a data cache, implement asynchronous operations, and so on, not one by one for example.
Installation of MSMQ
We need to install MSMQ when we are using MSMQ, please click here for specific steps. When we properly installed MSMQ we can find the installed MSMQ service in "Computer Management (local)", as
On the graph we can see the system's message queue, providing us with 3 queue outgoing queues, private queues and system queues, while the user is free to create only private queues. We can try to create a dedicated queue, "Right-click" the dedicated queue, and then click "New" to get a new interface such as. Since we are creating a dedicated queue, adding "private$" as shown above the queue naming, and another transaction check box indicates that we are creating a queue as a transaction queue, which I'll explain in more detail later.
I add a dedicated queue called "Shaoshun" in the private queue, which can be found under the private queue folder.
News
The message is the storage object of MSMQ, encapsulated as a System.Messaging.Message object, which consists of a body (body) and a number of attributes, where our user data is usually made into the body body, which is why we call it a data container. In addition to the Body property, there are several properties that are relatively important: priority (message precedence), Label (user-defined message identifier), Formatter (the sequence component of the message, when the user populates the complex type data into the body, the user's data is first serialized)
Queue
In front, we created a private queue by hand. We know that queues are divided into transactional and non-transactional queues, which are created by default for non-transactional queues. When we tick the transactional checkbox, we create a transactional queue, so what is a transactional queue? The transactional queue saves the message on disk and is persisted, that is, when we turn off the machine, the next time we power down, the machine will be restarted, and our messages will remain in the queue. Instead of a transactional queue, the message is saved in memory, which means that the message will not exist in the queue after I restart the computer.
The queue supports transactional operations, and when we incorporate a receive operation for multiple messages into a transaction, the queue discards all previously received messages and implements the transaction rollback as long as one message is received unsuccessfully. The queue transaction supports both receiving and sending messages sequentially.
End
In this article I have described the related concepts of MSMQ, and in the next article, I will describe the general operations of MSMQ in. NET by using code.
Transfer from http://www.cnblogs.com/shaoshun/p/3800208.html
MSMQ (Message Queuing)