home *** CD-ROM | disk | FTP | other *** search
-
- <!-- #include virtual="/quickstart/howto/include/header.inc" -->
-
- <h4>How Do I...Send a message to a message queue?</h4>
-
- <div class="indent" style="width:660">
- <p style="margin-right: 0; margin-top: 6; margin-bottom: 5"><font face="Tahoma" size="1">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.<br>
- <br>
- 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.<br>
- <br>
- 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:<br>
- <br>
- </font><font color="#0000FF" face="Courier New" size="2">
- > MQSend.exe MyQueue "Hello World!"</font><font face="Tahoma" size="1"><br>
- <br>
- Now, open the Message Queuing console and examine the MyQueue message queue. It
- should have a message in it.<br>
- <br>
- In its simplest form, sending a message to a message queue involves:</font></p>
- <p style="word-spacing: 0; margin-top: 0; margin-bottom: 0"> </p>
- <p style="word-spacing: 0; margin-top: 0; margin-bottom: 0"><font face="Tahoma" size="1">1.
- Creating an instance of the MessageQueue component and setting its Path
- property:</font></p>
- <p style="word-spacing: 0; margin-top: 0; margin-bottom: 0"> </p>
- <blockquote>
- <p style="word-spacing: 0; margin-top: 0; margin-bottom: 0"><font face="Courier New" size="2" color="#0000FF">MessageQueue
- mq = new MessageQueue(".\\MyQueue");</font></p>
- </blockquote>
- <p style="word-spacing: 0; margin-top: 0; margin-bottom: 0"> </p>
- <p style="word-spacing: 0; margin-top: 0; margin-bottom: 0"><font face="Tahoma" size="1">2.
- Calling Send method to send the message:</font></p>
- <p style="word-spacing: 0; margin-top: 0; margin-bottom: 0"> </p>
- <blockquote>
- <p style="word-spacing: 0; margin-top: 0; margin-bottom: 0"><font face="Courier New" size="2" color="#0000FF">mq.Send("Hello
- World!");</font></p>
- </blockquote>
- <p style="word-spacing: 0; margin-top: 0; margin-bottom: 0"><font face="Tahoma" size="1">Have
- a good time MessageQueue'ing!</font>
- </div>
-
- <h4>Example</h4>
-
- <p>
- <div class="indent">
- <a target="_blank" href="/quickstart/howto/samples/Services/MessageQueue/MQSend">
- <img style="border-color:black" border=1 src="/quickstart/images/genicon.gif"><br>
- </a>
- <div class="caption">MQSend.exe</div><br>
- [<a target="_blank" href="/quickstart/howto/samples/Services/MessageQueue/MQSend">View Sample</a>] |
- [<a target="_blank" href="/quickstart/util/srcview.aspx?path=/quickstart/howto/samples/Services/MessageQueue/MQSend/MQSend.src">View Source</a>]<p>
- </div>
-
- <h4>Source Code</h4>
-
- <div class="code">
- <xmp>
- <!-- #include virtual="/quickstart/howto/samples/Services/MessageQueue/MQSend/MQSend.cs" -->
- </xmp>
- </div>
-
- <!-- #include virtual="/quickstart/howto/include/footer.inc" -->