home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 February / CHIP_2_98.iso / software / pelne / optionp / iis4_07.cab / TransactedDelivery_JScript.asp < prev    next >
Text File  |  1997-10-25  |  3KB  |  98 lines

  1. <%@ TRANSACTION=REQUIRED LANGUAGE=JScript %>
  2.  
  3. <HTML>
  4.     <HEAD>
  5.         <TITLE>Transacted MSMQ Transmission</TITLE>
  6.     </HEAD>
  7.  
  8.     <BODY bgcolor="white" topmargin="10" leftmargin="10">
  9.  
  10.         
  11.         <!-- Display Header -->
  12.  
  13.         <font size="4" face="Arial, Helvetica">
  14.         <b>Transacted MSMQ Transmission</b></font><br>
  15.       
  16.         <hr size="1" color="#000000">
  17.  
  18.         This sample demonstrates how to send a transacted asynchronous message using 
  19.         the Microsoft Message Queueing Server (MSMQ).  MSMQ is one of the components
  20.         that comes with the Windows NT 4.0 Option Pack.
  21.   
  22.         <p> For this example to work, MSMQ must be first be installed on the host machine.
  23.         Using the MSMQ Explorer, a queue named "IIS_SDK_TRANSACTED" should then be created.  
  24.         Please click the "transacted" option when creating the queue.
  25.  
  26.         <p>After the example is run, return to the MSMQ Explorer and select "Refresh" from
  27.         the "View" menu.  The recently sent message will then appear within the "IIS_SDK_TRANSACTED"
  28.         queue.
  29.  
  30.         <%
  31.             // Create MSMQQueueInfo Component to
  32.             // Open MessageQueue
  33.  
  34.             QueueInfo = Server.CreateObject("MSMQ.MSMQQueueInfo")
  35.  
  36.  
  37.             // Open Queue.  The queue could be physically located
  38.             // on any machine.  The period in the line below indicates
  39.             // that the queue is located on the local machine.  Note
  40.             // that because JScript is being used as the scripting
  41.             // language, and extra backslash must be inserted
  42.             // as an escape character.
  43.  
  44.             QueueInfo.pathname = ".\\IIS_SDK_TRANSACTED";
  45.             Queue = QueueInfo.Open(2, 0);
  46.  
  47.  
  48.             // Create Message Component for Queue
  49.             
  50.             Msg = Server.CreateObject("MSMQ.MSMQMessage");
  51.  
  52.  
  53.             // Construct Message.  Anything can be passed into
  54.             // both the body and label.  The developer is responsible
  55.             // for marshalling all arguments.  Note that the delivery
  56.             // property has been sent to "Recoverable".  This will
  57.             // guarentee that the message will survive a crash or
  58.             // shutdown on the queue machine.
  59.             
  60.             Msg.body = "This is the message body";
  61.             Msg.Label = "This is the message label";
  62.             Msg.Delivery = 1;
  63.  
  64.  
  65.             // Send Message
  66.             
  67.             Msg.Send(Queue);
  68.  
  69.  
  70.             // Close Queue
  71.             
  72.             Queue.Close();
  73.         %>
  74.  
  75.     </BODY>
  76. </HTML>
  77.  
  78. <% 
  79.     // The Transacted Script Commit Handler.  This function
  80.     // will be called if the transacted script commits.
  81.  
  82.     function OnTransactionCommit()
  83.     {
  84.         Response.Write ("<p><b>The Transaction just comitted</b>.");
  85.         Response.Write ("The MSMQ message was <b>successfully</b> sent");
  86.     }
  87.  
  88.  
  89.     // The Transacted Script Abort Handler.  This function
  90.     // will be called if the script transacted aborts
  91.  
  92.     function OnTransactionAbort()
  93.     {
  94.         Response.Write ("<p><b>The Transaction just aborted</b>.");
  95.         Response.Write ("The MSMQ message was <b>not</b> sent");
  96.     }
  97. %>
  98.