How to Manage Routes

For the latest version of Commerce Server 2007 Help, see the Microsoft Web site.

The CReplicationRoute object provides the functionality to manage routes. To use a route, you first add the route to each server in the staging route topology. Then you add the route to the staging projects.

Note

A license for Commerce Server Staging (CSS) is required for each server that is defined in a route. This includes servers whose role is that of a waypoint. You must have CSS administrator rights to create and manage routes.

To add a route to a server

  1. Create a CReplicationServer object.

  2. Call the CReplicationServer.Initialize method to initialize the object.

  3. Add the route by calling the CReplicationServer.AddRoute method, specifying the route name. Route names must consist of alphanumeric characters and must not exceed 49 characters.

  4. Call the CReplicationRoute.AddDestination method to specify the name of a server that is either a waypoint or a destination for the route on the server.

  5. Repeat step 4 for each waypoint or destination that is contained in the route.

  6. Set the CReplicationRoute.BaseDirectory property to specify the local directory to use for storing temporary files.

  7. Call the CReplicationRoute.Commit method to commit the changes that you made for the route.

To remove a route from a server

  1. Create a CReplicationServer object.

  2. Initialize the object by calling the CReplicationServer.Initialize method.

  3. Call the CReplicationServer.DeleteRoute method to delete the route. Specify the name of the route to delete.

To add an existing route as a destination to an existing project

  1. Create a CReplicationServer object.

  2. Initialize the object by calling the CReplicationServer.Initialize method.

  3. Call the CReplicationServer.OpenProject method, specifying the OPEN_EXISTING_PROJECT flag and the name of an existing project.

  4. Add the route to the opened project by calling the CReplicationProject.AddDestination method.

  5. Call the CReplicationProject.Commit method to commit the changes that you made to the project.

To retrieve the destinations defined for a route

  1. Create a CReplicationServer object.

  2. Initialize the object by calling the CReplicationServer.Initialize method.

  3. Iterate to retrieve the names of the destinations defined for a route. Call the CReplicationRoute.EnumDestination method.

To retrieve the routes defined on a server

  1. Create a CReplicationServer object.

  2. Initialize the object by calling the CReplicationServer.Initialize method.

  3. Iterate to retrieve the names of the routes defined on the server. Call theCReplicationServer.EnumRoutes method.

Example

The following example creates a new route named Default and sets the base directory for this route to D:\Stress.

CReplicationServer replicationServer = new CReplicationServer();
  replicationServer.Initialize("");
  CReplicationRoute replicationRoute = (CReplicationRoute)replicationServer.AddRoute("Default");
  replicationRoute.set_BaseDirectory(@"D:\Stress");
  replicationRoute.Commit();

The following example lists the destinations defined for the route named Temp.

CReplicationServer replicationServer = new CReplicationServer();
replicationServer.Initialize("");
CReplicationRoute replicationRoute;
int i = 0;
object iterator1 = i as object;
// Get route "Temp" and list its destinations
while (true)
  {
  try
    {
    replicationRoute = replicationServer.EnumRoutes(ref iterator1) as CReplicationRoute;
    if (replicationRoute.get_Name().ToString() == "Temp")
      {
      Console.WriteLine("The Temp route has the following destinations:");
      int j = 0;
      object iterator2 = j as object;
      while (true)
        {
        try
          {
          Console.WriteLine(replicationRoute.EnumDestination(ref iterator2).ToString());
          }
        catch (System.Runtime.InteropServices.COMException e)
          {
            if (e.ErrorCode == -2147422485)
               break;
            else
               throw e;
           }
        }
        break;
      }
    }
    catch (System.Runtime.InteropServices.COMException e)
    {
      // Quit if "No more items" or "No routes" error
      if (e.ErrorCode == -2147422485 || e.ErrorCode == -1073680678)
        break;
      else
        throw;
    }
  }

See Also

Other Resources

Routes

What are the Staging API Concepts?

Why Define Routes for Staging?

Configuring Routes for Staging

CReplicationRoute Class

CReplicationProject Class

CReplicationServer Class

Managing Projects and Routes by using the Staging API