Order Queuing Sample

Location in SDK: SDK\Samples\Order Processing\Queuing

The Microsoft Commerce Server 2002 Software Development Kit (SDK) includes the Order Queuing sample that contains components that you can use for queuing orders so you can process them at a later time. Providing the capability to process orders offline is a recommended best practice for high-availability sites.

The Order Queuing sample integrates Message Queuing, which allows an order to be stored in a queue until a server or database becomes available. Message Queuing ensures that users are not affected by server or database outages, and efficiently and accurately stores orders when real-time processing is not a viable option.

Diagram depicting the workflow of the Order Queuing sample.

When order queuing is implemented, the IPersistXML interface is used to convert an order into XML-formatted text. This text is saved in the message queue. The Order Queuing sample includes a sample Reader application that allows you to view the XML-formatted version of the order and save it to the orders database as an OrderGroup object, or return it to the queue for processing at a later time. It is recommended that a custom Reader application be created for use in production Web sites to automate the polling of the order queue.

For more information about message queuing, see the Message Queuing topics available in the Platform SDK in the online MSDN Library (https://go.microsoft.com/fwlink/?LinkId=6680).

This section contains:

  • Order Queuing Sample Code Walkthrough
  • Installing the Order Queuing Sample

Order Queuing Sample Code Walkthrough

The Order Queuing sample includes a writer component (writeorder.cls) and a reader component (readorder.cls). The writer component stores the orders in a private queue. This component should be used in a site or sitelet to store the order in the queue instead of in the orders database. The reader component reads orders from the queue and stores them in your Commerce Server orders database.

The reader application, ReaderApp.exe, is a sample application provided to exemplify one way in which the reader component can be used. The reader application initializes the components, reads the order from the queue where it is stored as XML, returns the OrderGroup object, and then calls the function SaveAsOrder to write the order to the orders database.

Installing the Order Queuing Sample

Use the following procedures to install the Order Queuing sample. After you have installed the code to run the sample, you will need to make the OrderQueue.dll file, make the ReaderApp.exe file, and register the OrderQueue.dll file. You will then need to reset Internet Information Services (IIS).

Ee811727.note(en-US,CS.20).gif Notes

  • Before installing the Order Queuing sample, the Order Sitelet must be installed. For more information about installing the Order Sitelet, see Installing the ASP-Based Order Sitelet.
  • Before installing the Order Queuing sample, the Message Queuing Services component in Windows 2000 must be installed on the same computer as the Order Sitelet. The Message Queuing Services component can be installed through the Windows Components Wizard, which is accessible through Control Panel, Add/Remove Programs, Add/Remove Windows Components.
  • Before installing the Order Queuing sample, Microsoft Visual Studio 6.0 must be installed on the same computer as the Order Sitelet.

To install the Order Queuing sample

To make the OrderQueue.dll file

To make the ReaderApp.exe file

To register the OrderQueue.dll file

To reset IIS

To run the Order Queuing sample

To install the Order Queuing sample

  1. Click Start, point to Programs, point to Accessories, and then click Windows Explorer.

  2. Navigate to the global.asa file located at <drive>:\Inetpub\wwwroot\ordersitelet\global.asa.

  3. Right-click the Global.asa file, point to Open With, and then select your preferred editor

    In this example, the text editor is WordPad.

  4. Paste the following code into the global.asa file, in the Main function following the line of code Set Application("MSCSExpressionEvaluator") = MSCSExpressionEvaluator:

    Dim MSCSWriteToQueue 
    
    Set MSCSWriteToQueue = CreateObject("OrderQueue.WriteOrder")
    Call MSCSWriteToQueue.Initialize ("ordersitelet")   
    
    
    Set Application("MSCSWriteToQueue") = MSCSWriteToQueue  
    
    
  5. On the File menu, click Save.

  6. On the File menu, click Open, navigate to the orderlib.asp file located at <drive>:\Inetpub\wwwroot\ordersitelet\Include\orderlib.asp, and then click Open.

  7. Comment out the following line of code in the CompleteOrder function of the file orderlib.asp:

    ' Call oBasket.SaveAsOrder()
    
  8. Paste the following code into the CompleteOrder function in the file orderlib.asp after the line of code ' Call oBasket.SaveAsOrder():

    Dim oWriter
    Set oWriter = Application("MSCSWriteToQueue")
    Call oWriter.WriteToQueue(oBasket)
    
  9. On the File menu, click Save, and then click Exit.

To make the OrderQueue.dll file

  1. Click Start, point to Programs, point to Microsoft Visual Studio 6.0, and then click Microsoft Visual Basic 6.0.
  2. On the File menu, click Open Project, navigate to the OrderQueue.vbp file located at <drive>:\Program Files\Microsoft Commerce Server\SDK\Samples\Order Processing\Queuing\Component\OrderQueue.vbp, and then click Open.
  3. On the File menu, click Make OrderQueue.dll.
  4. In the Make Project dialog box, click OK.
  5. On the File menu, click Save Project.

To make the ReaderApp.exe file

  1. In Microsoft Visual Basic 6.0, on the File menu, click Open Project, navigate to the ReaderApp.vbp file located at <drive>:\Program Files\Microsoft Commerce Server\SDK\Samples\Order Processing\Queuing\ReaderApp.vbp, and then click Open.
  2. On the File menu, click Make ReaderApp.exe.
  3. In the Make Project dialog box, click OK.
  4. On the File menu, click Save Project, and then click Exit.

You can now register the OrderQueue.dll file.

To register the OrderQueue.dll file

  1. Click Start, and then click Run.

  2. In the Run dialog box, in the Open box, type regsvr32 "<drive>:\Program Files\Microsoft Commerce Server\SDK\Samples\Order Processing\Queuing\Component\OrderQueue.dll", and then click OK.

    After the registration succeeds, the RegSvr32 dialog box appears.

  3. In the RegSvr32 dialog box, click OK.

To reset IIS

  1. Click Start, and then click Run.
  2. In the Run dialog box, in the Open box, type iisreset, and then click OK.

A command box appears while IIS is being reset. IIS is reset when the command box closes.

To run the Order Queuing sample

  1. Click Start, point to Programs, and then click Internet Explorer.

  2. In Internet Explorer, in the Address box, type http://<servername**>/ordersitelet**, and then press ENTER.

    The default.asp page for the Order Sitelet appears.

  3. Place a sample order in the Order Sitelet following the on-screen directions.

  4. After placing the order and receiving order confirmation, open the ReaderApp.exe file located at <drive>:\Program Files\Microsoft Commerce Server\SDK\Samples\Order Processing\Queuing\ReaderApp\ReaderApp.exe.

  5. In the Read Order From Queue dialog box, in the Site name box, type the name of the site (for example, OrderSitelet).

  6. Click ReadOrder to read the first order from the queue.

The order is read from the queue and displayed in the Order details box.

  1. Click OK to save the order to the database.

    Ee811727.note(en-US,CS.20).gifNote

    • Clicking Cancel will return the order to the queue and close the application.
  2. Repeat steps 6 and 7 until all orders have been read from the queue.

  3. To close the Read Order from Queue dialog box, click Cancel.

Copyright © 2005 Microsoft Corporation.
All rights reserved.