Message Queue Introduction and Application

xiaoxiao2021-03-06  41

First, the main concept "message" in message processing is the data unit transmitted between two computers. The message can be very simple, such as only a text string; it is more complicated, which may contain embedded objects.

The message is sent to the queue. "Message Queue" is a container that saves a message during the transmission of the message. Message Queue Manager acts as an intermediary when returning messages from its source. The main purpose of the queue is to provide routing and guarantee the delivery of messages; if the recipient is not available when sending a message, the message queue retains the message until it can be successfully delivered.

"Message Queue" is Microsoft message processing technology, which provides message processing and message queue feature for any application in any application, whether or not the computers are on the same network or whether they online.

The Message Queue Network is any set of computers that can send messages to each other. Different computers in the network play different roles in the process of ensuring the smooth processing of messages. They provide routing information to determine how to send messages, some of which are important information for the entire network, and some only send and receive messages.

During the "Message Queue" installation, the administrator determines which servers can communicate with each other and set special roles of a particular server. Computers constituting this "Message Queue" network are called "sites", they are connected to each other by "Site Link". Each site link has an associated "overhead", which is determined by the administrator, indicating the frequency of the message passing through this site.

The Message Queue administrator also sets one or more computers that are "routing servers" in the network. The routing server views the overhead of each site link to determine the fastest and most effective way to pass the messages through multiple sites to determine how to deliver messages. Second, the queue type has two main queue types: queues and system queues created by other users in you or network. The queue created by the user may be any of the following queues:

"Public Square" is copied throughout the "Message Queue" network and is possible to access all sites connected by the network. "Special queue" is not released throughout the network. Instead, they are only available on the resident local computer. A dedicated queue can only be accessed by an application that knows the full path name or tag of the queue. The Manage Query contains messages that confirm the message receipt of the message sent in a given "Message Queue" network. Specifies the management queue you want to use by the MessageQueUE component (if any). The Response Queue contains a response message to send an application when the target application receives a message. Specifies the response queue (if any if any) you want the MessageQue component. The queue generated by the system is generally divided into the following categories:

"Diary Queue" optionally stores a copy of the send message and a copy of the message removed from the queue. A single diary queue on each "Message Queue" client stores the message replica sent from the computer. A separate diary queue is created for each queue on the server. This diary tracks the message removed from the queue. "Dead Letter Queue" stores a copy of the message that cannot be passed or expired. If the message expired or unable to pass is a transactional message, it is stored in a special dead letter queue, called "transactional dead letter queue". Dead letter is stored on a computer where expired message is located. The Report Queue contains messages that indicate the route passage through the message to the target, and can also contain test messages. There can only be a report queue on each computer. "Special System Query" is a special queue for the management and notification messages required by a series of storage systems to perform message processing operations. Most of the work conducted in the application involves accessing public queues and their messages. However, depending on the application's diary record, confirmation, and other special processing needs, several different system queues are likely to use in daily operations.

Third, synchronous and asynchronous communication queue communication is asynchronous because send messages to queues and receive messages from the queue are done in different processes. In addition, the reception operation can be performed asynchronously because people to receive the message can call the BeginReceive method for any given queue, and then immediately continue other tasks without waiting for a reply. This is very different from "synchronous communication" understanding.

In synchronous communication, the requested sender must wait for a response from a predetermined receiver before performing other tasks. The time of the sender waits for time depends entirely on the time used by the recipient processing request and the transmit response. Fourth, message security can help protect the message content of sending and receiving as follows: The source of the message received by the authentication verification application can be used. You can use encryption to ensure that unauthorized people cannot read or use your message. Access control permissions can be used to send messages to the computer with the specific queue on the computer with the code access security restriction code to send messages to the computer with the code access security restriction code. You can use the audit record to try to access the user of the Message Queue object, try the type of operation, and the success of the access or failure. V. Install the "Message Queue" If you want to use the message queue in the code or server Explorer, you must install "Message Queue" on the development computer. In the Windows 2000 or Windows NT documentation, you can find instructions on how to install "Message Queue". At the time of installation, you must specify the role of the new primary "message queue" server being created: is a hub that acts as a new network, the independent client of the existing network or the dependent network. In most cases, you don't have to create a new network, but you can join the existing "Message Queue" network of the company or workgroup. A message queue with a stand-alone client function is installed opens an addition or delete program. Click Add / Remove Windows Components. In the Windows Component Wizard, select the Message Queue check box. If you want to change the optional subcomponent set of the default installation, click Details and do the following. If your computer belongs to a domain, and you want it to run in Workgroup mode, clear the "Active Directory Integration" checkbox. Clear the Trigger check box if you do not want to install a message queue trigger. If you want to send messages by an HTTP transfer program, select the "MSMQ HTTP Support" checkbox. Six, instance analysis adds reference system.Messagingusing system.Messaging; // A file download message queue, store the download source file information and download target address information string filedownloadmq = @ "./ private $ / filedownloadjobs"; // Make sure message queue the presence if {MessageQueue.Create (fileDownloadMQ);} (MessageQueue.Exists (fileDownloadMQ)!) MessageQueue mq = new MessageQueue (fileDownloadMQ); // // operated can then send a message to the message queue, the queue increases A message system.Messaging.Message M = new message (); m.formatter = new xmlMessageFormatter (new string [] {"system.string, mscorlib"}; m.Label = "xxx"; m.body = "yyy "; M.Recoverable = true; mq.send (m); // receives a message, the queue is deleted System.Messaging.Message M = MQ.RecEive (MQTX); // You can get M.Label and M .Body performs processing // View a message, the queue does not delete the message system.Messaging.Message M = MQ.PEEK (MQTX); // Circularly PEEK will first get the message content, after processing is completed after processing.

转载请注明原文地址:https://www.9cbs.com/read-54265.html

New Post(0)