How Do I...Send a message to a message queue?
Message queuing makes it easy for application developers to communicate with application programs quickly and reliably by sending and
receiving messages. Messaging provides you with guaranteed message delivery and a robust, fail-safe way to carry
out many of your business processes.
The MessageQueue component allows you to easily incorporate message-based communication into your applications.
Using this component and its associated language features, you can send and receive messages, explore existing
queues, create and delete queues, and perform a variety of other operations using a simple programming model.
The sample illustrates how to use the MessageQueue component to send a simple
message to a message queue. To run the sample, you have to have Message Queuing
installed on your system. The sample is a command-line application that takes
two command-line arguments. The first argument is a name of a message
queue. The path does not have to refer to an existing queue. If the queue does
not exist, it will be created for you. The second command-line argument is the
message to be written to the queue. For example you can run it as follows:
MQSend.exe MyQueue "Hello World!"
Now, open the Message Queuing console and examine the MyQueue message queue. It
should have a message in it.
In its simplest form, sending a message to a message queue involves:
- Creating an instance of the MessageQueue component and setting its Path
MessageQueue mq = new MessageQueue(".\\MyQueue");
- Calling Send method to send the message:
[This sample can be found at C:\DevFusion.Data\legacy\quickstart.developerfusion.co.uk\QuickStart\howto\samples\Services\MessageQueue\MQSend\]
Microsoft .NET Framework SDK QuickStart Tutorials Version 2.0
Copyright � 2004 Microsoft Corporation. All rights reserved.