home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 9 / IOPROG_9.ISO / contrib / iis4 / iis4_07.cab / TransactedDelivery_VBScript.asp < prev    next >
Encoding:
Text File  |  1997-09-04  |  3.7 KB  |  115 lines

  1. <%@ TRANSACTION=REQUIRED LANGUAGE=VBScript %>
  2. <%  Option Explicit                        %>
  3.  
  4. <HTML>
  5.     <HEAD>
  6.         <TITLE>Transacted MSMQ Transmission</TITLE>
  7.     </HEAD>
  8.  
  9.     <BODY bgcolor="white" topmargin="10" leftmargin="10">
  10.  
  11.         
  12.         <!-- Display Header -->
  13.  
  14.         <font size="4" face="Arial, Helvetica">
  15.         <b>Transacted MSMQ Transmission</b></font><br>
  16.       
  17.         <hr size="1" color="#000000">
  18.  
  19.         This sample demonstrates how to send a transacted asynchronous message using 
  20.         the Microsoft Message Queueing Server (MSMQ).  MSMQ is one of the components
  21.         that comes with the Windows NT 4.0 Option Pack.
  22.   
  23.         <p> This sample will open the "IIS_SDK_TRANSACTED" queue located on the local
  24.         machine, and transmit a message to it.  Because the "IIS_SDK_TRANSACTED" queue
  25.         has been created as a transacted queue, and the components on this page
  26.         are wrapped by an ASP transaction, the message sent from this page will be transacted.
  27.  
  28.         <p> Transacted transmission of MSMQ messages means that the message transmission
  29.         will be combined with the other actions of this page into a single atomic unit of
  30.         work.  If any of the updates that occur within this ASP fail, then all of the updates
  31.         will rollback to their previous state.  In the case of the MSMQ message, the message
  32.         will not be sent if the transaction aborts.  If the transaction commits, then the 
  33.         message is guarenteed to arrive at its destination.
  34.  
  35.         <p> For this example to work, MSMQ must be first be installed on the host machine.
  36.         Using the MSMQ Explorer, a queue named "IIS_SDK_TRANSACTED" should then be created.  
  37.         Please click the "transacted" option when creating the queue.
  38.  
  39.         <p>After the example is run, return to the MSMQ Explorer and select "Refresh" from
  40.         the "View" menu.  The recently sent message will then appear within the "IIS_SDK_TRANSACTED"
  41.         queue.
  42.  
  43.         <%
  44.             Dim QueueInfo
  45.             Dim Queue
  46.             Dim Msg
  47.  
  48.  
  49.             ' Create MSMQQueueInfo Component to Open
  50.             ' MessageQueue
  51.  
  52.             Set QueueInfo = Server.CreateObject("MSMQ.MSMQQueueInfo")
  53.  
  54.  
  55.             ' Open Queue.  The queue could be physically located
  56.             ' on any machine.  The period in the line below indicates
  57.             ' that the queue is located on the local machine.
  58.  
  59.             QueueInfo.pathname = ".\IIS_SDK_TRANSACTED"
  60.             Set Queue = QueueInfo.Open(2, 0)
  61.  
  62.  
  63.             ' Create Message Component for Queue
  64.             
  65.             Set Msg = Server.CreateObject("MSMQ.MSMQMessage")
  66.  
  67.  
  68.             ' Construct Message.  Anything can be passed into both
  69.             ' the body and label.  The developer is responsible
  70.             ' for marshalling all arguments.  Note that the
  71.             ' delivery property has been sent to "Recoverable".
  72.             ' This will guarentee that the message will survive
  73.             ' a crash or shutdown on the queue machine.
  74.             
  75.             Msg.body = "This is the message body"
  76.             Msg.Label = "This is the message label"
  77.             Msg.Delivery = 1
  78.  
  79.  
  80.             ' Send Message
  81.             
  82.             Msg.Send Queue
  83.  
  84.  
  85.             ' Close Queue
  86.             
  87.             Queue.Close
  88.         %>
  89.  
  90.     </BODY>
  91. </HTML>
  92.  
  93. <% 
  94.     ' The Transacted Script Commit Handler.  This function
  95.     ' will be called if the transacted script commits.
  96.  
  97.     Sub OnTransactionCommit
  98.     
  99.         Response.Write "<p><b>The Transaction just comitted</b>."
  100.         Response.Write "The MSMQ message was <b>successfully</b> sent"
  101.  
  102.     End Sub
  103.  
  104.  
  105.     ' The Transacted Script Abort Handler.  This function
  106.     ' will be called if the script transacted aborts
  107.  
  108.     Sub OnTransactionAbort
  109.     
  110.         Response.Write "<p><b>The Transaction just aborted</b>."
  111.         Response.Write "The MSMQ message was <b>not</b> sent"
  112.     
  113.     End Sub
  114. %>
  115.