One, Windows 7 installation, management Message Queuing
1. Install Message Queuing
The execution user must have membership in the local Administrators group, or an equivalent identity.
Specific steps:
Start-"Control Panel-" program-"programs and Features-" turn Windows features on or off-"Expand the Microsoft Message Queue (MSMQ) server, click Microsoft Message Queue (MSMQ) Server Core-" to determine
If you are prompted to restart your computer, click OK to complete the installation.
2. Manage Message Queuing
Computer-right-manage-services and applications-Message Queuing.
ii. Windows Server 2008 installation, managing Message Queuing
1. Install Message Queuing
Start-"Control Panel-" Management tools-"Server Manager-" function-"Add function-" expand MSM, MSMQ service-"OK."
2. Manage Message Queuing
Computer-Right-"manage-" function-"message queue.
Iii. Creating, deleting, and managing queues
To develop an MSMQ program, you must learn a very important class (MessageQueue), which is located under namespace system.messageing.
Common methods:
--create () Method: Creates a new message queue using the specified path.
--delete () Method: Deletes an existing message queue.
--existe () Method: see if the specified message queue exists.
--getallmessages () Method: Gets all the messages in the queue.
--getpublicqueues () method: Locate Message Queuing in the Message Queuing network.
--peek ()/beginpeek () method: View Message Queuing in a particular queue, but do not remove messages from the queue.
--receive ()/beginreceive () method: Retrieves the first message in the specified message queue and removes it from the queue.
--send () Method: Sends a message to the specified message queue.
--purge () Method: Clears the message for the specified queue.
Common Properties:
--priority: Set message priority, Messagepriority enumeration is all encapsulated, Messagepriority.high ();
Between the abovenormal:hight and the normal message priority;
High: Advanced message priority;
Highest: Highest message priority;
Low: Lower message priority;
Lowest: Lowest message priority;
Normal: Normal message priority;
Between the veryhigh:highest and the high message priority;
Between Verylow:low and lowest message priority;
Iv. Sending and serializing messages
Messages defined in the MSMQ message queue consist of a principal (body) and several attributes. The body of the message can be composed of text, binary, and optionally encrypted as needed.
The message size cannot exceed 4MB in MSMQ. Sending a message is done through the Send method and requires a message parameter.
1. Send message:
Step: Connect the queue--Specify the message format--Provide the data to be sent (the body)--and call the Send () method to send the message out. See the example program in detail later.
2. Serialization of messages:
Message serialization can be accomplished through the three predefined formatters that are included with the. NET Framework:
--XMLMessageFormatter Object----The default formatter settings for the MessageQueue component.
--BinaryMessageFormatter object;
--ActiveXMessageFormatter object;
Since the latter two formatted messages are usually not readable for people, we often use xmlmessageformatter objects. There are three overloads of this object construction method:
1, public xmlmessageformatter ();
2, public XMLMessageFormatter (string[] targettypenames);
3, public XMLMessageFormatter (type[] targettypes);
The serialized statement used in the example program that follows us:
Serialized to a string
XMLMessageFormatter formatter = new XMLMessageFormatter (new type[] {typeof (String)});
v. Read and receive Messages
1. Read the message:
That is to get the message from the specified queue.
2. There are two ways of receiving messages:
--Through the receive () method.
--Through the Peek () method.
Original:
http://blog.csdn.net/kingcruel/article/details/8241142
"Go" MSMQ Message Queuing installation