home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 9 / IOPROG_9.ISO / contrib / iis4 / iis4_07.cab / TransactedDelivery_JScript.asp < prev    next >
Encoding:
Text File  |  1997-09-04  |  3.8 KB  |  110 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> This sample will open the "IIS_SDK_TRANSACTED" queue located on the local
  23.         machine, and transmit a message to it.  Because the "IIS_SDK_TRANSACTED" queue
  24.         has been created as a transacted queue, and the components on this page
  25.         are wrapped by an ASP transaction, the message sent from this page will be transacted.
  26.  
  27.         <p> Transacted transmission of MSMQ messages means that the message transmission
  28.         will be combined with the other actions of this page into a single atomic unit of
  29.         work.  If any of the updates that occur within this ASP fail, then all of the updates
  30.         will rollback to their previous state.  In the case of the MSMQ message, the message
  31.         will not be sent if the transaction aborts.  If the transaction commits, then the 
  32.         message is guarenteed to arrive at its destination.
  33.  
  34.         <p> For this example to work, MSMQ must be first be installed on the host machine.
  35.         Using the MSMQ Explorer, a queue named "IIS_SDK_TRANSACTED" should then be created.  
  36.         Please click the "transacted" option when creating the queue.
  37.  
  38.         <p>After the example is run, return to the MSMQ Explorer and select "Refresh" from
  39.         the "View" menu.  The recently sent message will then appear within the "IIS_SDK_TRANSACTED"
  40.         queue.
  41.  
  42.         <%
  43.             // Create MSMQQueueInfo Component to
  44.             // Open MessageQueue
  45.  
  46.             QueueInfo = Server.CreateObject("MSMQ.MSMQQueueInfo")
  47.  
  48.  
  49.             // Open Queue.  The queue could be physically located
  50.             // on any machine.  The period in the line below indicates
  51.             // that the queue is located on the local machine.  Note
  52.             // that because JScript is being used as the scripting
  53.             // language, and extra backslash must be inserted
  54.             // as an escape character.
  55.  
  56.             QueueInfo.pathname = ".\\IIS_SDK_TRANSACTED";
  57.             Queue = QueueInfo.Open(2, 0);
  58.  
  59.  
  60.             // Create Message Component for Queue
  61.             
  62.             Msg = Server.CreateObject("MSMQ.MSMQMessage");
  63.  
  64.  
  65.             // Construct Message.  Anything can be passed into
  66.             // both the body and label.  The developer is responsible
  67.             // for marshalling all arguments.  Note that the delivery
  68.             // property has been sent to "Recoverable".  This will
  69.             // guarentee that the message will survive a crash or
  70.             // shutdown on the queue machine.
  71.             
  72.             Msg.body = "This is the message body";
  73.             Msg.Label = "This is the message label";
  74.             Msg.Delivery = 1;
  75.  
  76.  
  77.             // Send Message
  78.             
  79.             Msg.Send(Queue);
  80.  
  81.  
  82.             // Close Queue
  83.             
  84.             Queue.Close();
  85.         %>
  86.  
  87.     </BODY>
  88. </HTML>
  89.  
  90. <% 
  91.     // The Transacted Script Commit Handler.  This function
  92.     // will be called if the transacted script commits.
  93.  
  94.     function OnTransactionCommit()
  95.     {
  96.         Response.Write ("<p><b>The Transaction just comitted</b>.");
  97.         Response.Write ("The MSMQ message was <b>successfully</b> sent");
  98.     }
  99.  
  100.  
  101.     // The Transacted Script Abort Handler.  This function
  102.     // will be called if the script transacted aborts
  103.  
  104.     function OnTransactionAbort()
  105.     {
  106.         Response.Write ("<p><b>The Transaction just aborted</b>.");
  107.         Response.Write ("The MSMQ message was <b>not</b> sent");
  108.     }
  109. %>
  110.