home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 40 / IOPROG_40.ISO / SOFT / NETFrameworkSDK.exe / comsdk.cab / samples.exe / QuickStart / howto / doc / mqreceive.aspx < prev    next >
Encoding:
Text File  |  2000-06-08  |  3.9 KB  |  72 lines

  1.  
  2. <!-- #include virtual="/quickstart/howto/include/header.inc" -->
  3.  
  4. <h4>How Do I...Receive a message from a message queue?</h4>
  5.  
  6. <div class="indent" style="width:660">
  7. <p style="margin-right: 0; margin-top: 6; margin-bottom: 5"><font face="Tahoma" size="1">Message queuing makes 
  8. it easy for application developers to communicate with application programs quickly and reliably by sending and 
  9. receiving messages. Messaging provides you with guaranteed message delivery and a robust, fail-safe way to carry 
  10. out many of your business processes.<br>
  11. <br>
  12. The MessageQueue component allows you to easily incorporate message-based communication into your applications. 
  13. Using this component and its associated language features, you can send and receive messages, explore existing 
  14. queues, create and delete queues, and perform a variety of other operations using a simple programming model.<br>
  15. <br>
  16. The sample illustrates how to use the MessageQueue component to receive a
  17. message from a message queue. To run the sample you have to have Message Queuing
  18. installed on your system. The sample is a command line application that takes
  19. one command line argument. The argument is the name of a public message queue on
  20. your local machine. For example you can run it as follows (first send a message
  21. to the queue using the MQSend sample):</font>
  22. <p style="margin-right: 0; margin-top: 6; margin-bottom: 5"><font face="Tahoma" size="1"><br>
  23. </font><font face="Courier New" size="2" color="#0000FF">   </font><font face="Tahoma" size="1">
  24. </font><font face="Courier New" size="2" color="#0000FF">> MQReceive.exe MyQueue</font><font face="Tahoma" size="1"><br>
  25. <br>
  26. The sample application will receive and output to the console the first message
  27. from the queue.<br>
  28. </font></p>
  29. <p style="MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px; WORD-SPACING: 0px"><font face="Tahoma" size="1">In
  30. its simplest form, receiving a message from a message queue involves:</font></p>
  31. <p style="MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px; WORD-SPACING: 0px"> </p>
  32. <p style="MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px; WORD-SPACING: 0px"><font face="Tahoma" size="1">1.
  33. Creating an instance of the MessageQueue component and setting its Path
  34. property:</font></p>
  35. <p style="MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px; WORD-SPACING: 0px"> </p>
  36. <blockquote>
  37.   <p style="MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px; WORD-SPACING: 0px"><font face="Courier New" color="#0000ff" size="2">MessageQueue
  38.   mq = new MessageQueue(".\\MyQueue");</font></p>
  39. </blockquote>
  40. <p style="MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px; WORD-SPACING: 0px"> </p>
  41. <p style="MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px; WORD-SPACING: 0px"><font face="Tahoma" size="1">2.
  42. Calling Receive to receive the message:</font></p>
  43. <p style="MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px; WORD-SPACING: 0px"> </p>
  44. <blockquote>
  45.   <p style="MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px; WORD-SPACING: 0px"><font face="Courier New" color="#0000ff" size="2">Message m = mq.Receive(1000);<br>
  46.   Console.WriteLine((string)m.Body);</font></p>
  47. </blockquote>
  48. <p style="MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px; WORD-SPACING: 0px"><font face="Tahoma" size="1">Have
  49. a good time MessageQueue'ing!</font>
  50. </div>
  51.  
  52. <h4>Example</h4>
  53.  
  54. <p>
  55. <div class="indent">
  56. <a target="_blank" href="/quickstart/howto/samples/Services/MessageQueue/MQReceive">
  57. <img style="border-color:black" border=1 src="/quickstart/images/genicon.gif"><br>
  58. </a>
  59. <div class="caption">MQReceive.exe</div><br>
  60. [<a target="_blank" href="/quickstart/howto/samples/Services/MessageQueue/MQReceive">View Sample</a>] | 
  61. [<a target="_blank" href="/quickstart/util/srcview.aspx?path=/quickstart/howto/samples/Services/MessageQueue/MQReceive/MQReceive.src">View Source</a>]<p>
  62. </div>
  63.  
  64. <h4>Source Code</h4>
  65.  
  66. <div class="code">
  67. <xmp>
  68. <!-- #include virtual="/quickstart/howto/samples/Services/MessageQueue/MQReceive/MQReceive.cs" -->
  69. </xmp>
  70. </div>
  71.  
  72. <!-- #include virtual="/quickstart/howto/include/footer.inc" -->