Setting Up the Pipeline and Cache

In the multiple-shipment shipping architecture, the Shipping stage of a pipeline contains two or three components: Splitter, ShippingMethodRouter, and occasionally the ShippingDiscountAdjust component. The Splitter component divides the order into a series of shipments; the ShippingMethodRouter component takes the shipments created by the Splitter component, checks the shipping method, and runs the appropriately configured shipping component.

In addition to including the two pipeline components in the pipeline, you need to add some Active Server Pages (ASP) code to your pages to handle setting up the CacheManager object and to provide the Context dictionary values expected by the Splitter and ShippingMethodRouter components.

Both the Splitter and ShippingMethodRouter components use the CacheManager object to retrieve information from the ShippingConfig database table. The CacheManager object, in turn, uses a loader component, ShippingManagerCache, to retrieve the information from the database. Setting up the CacheManager object for the shipping components is roughly the same as for any other component using the CacheManager object. Most of the code is contained in the Global.asa file, in the Application_OnStart procedure. For example:

'' Code to set up the CacheManager object and loader for the
'' multiple shipping components.

'' Create a Dictionary object to hold the configuration information.
Set dShipConfig = Server.CreateObject(""Commerce.Dictionary"")

'' Add the connection string to the configuration dictionary.
"dShipConfig(""ConnectionString"") = ""Provider=SQLOLEDB;" & _
"Data Source=servername;Integrated Security='SSPI';""

'' Create a CacheManager object.
Set oCM = Server.CreateObject(""Commerce.CacheManager"")

'' Set the ProgID of the loader for the cache.
oCM.LoaderProgId(""ShippingManagerCache"") = _ 

'' Set the loader's configuration dictionary.
Set oCM.LoaderConfig(""ShippingManagerCache"") = dShipConfig

'' Set the CacheManager object refresh interval to 10 minutes.
oCM.RefreshInterval(""ShippingManagerCache"") = 10 * 60

'' Set the CacheManager object retry interval to 1 minute.
oCM.RetryInterval(""ShippingManagerCache"") = 60

'' Store a reference to the CacheManager object in the Application object.
Set Application(""MSCSCacheManager"") = oCM

Note that in the preceding code, you must use the identifier ""ShippingManagerCache"" when setting the LoaderProgID, LoaderConfig, and other properties. On the page that runs the pipeline, only one additional line of code is needed:

'' Add the items specific to the shipping components.
''Add a reference to the CacheManager object created in the Global.asa file
''to the Context dictionary.
Set dContext(""CacheManager"") = Application(""MSCSCacheManager"")

The code to invoke the pipeline would follow this code.

See Also

Overview of the Multiple-shipment Shipping Architecture

Using the Splitter Component to Create Multiple Shipments

Previewing Shipping Costs

Adding Shipping Methods and Components

Shipping and Address Structures

Copyright © 2005 Microsoft Corporation.
All rights reserved.