Synchronizing Data Between Multiple Resources

Data Synchronization Overview

Often, multiple applications within an enterprise use equivalent data. For example, a Customer Relationship Management (CRM) system and a Billing system both contain information about customers. If the address for a customer changes, the change should be updated in both systems. Data synchronization keeps equivalent data across multiple systems consistent; that is, if data is changed in one application, a similar change is made to the equivalent data in all other applications.

Applications can be thought of as resources of data. (The remainder of this chapter will refer to applications as resources.) There are two methods for keeping data synchronized between resources:

  • One-way synchronization, in which one resource is the source of all data changes. When a data change is required, it is always made in the source. After a change is made, it is propagated to all other resources, which are referred to as the targets.

    For example, for data synchronization between a CRM system, Billing system, and Order Management system, the CRM might be the source of all changes and the Billing and Order Management systems receive changes made to the CRM system

  • N-way synchronization, in which every resource can be a source and a target as well. Changes to data can be made in any resource. After the change is made, it is propagated to all other resources.

    For example, for data synchronization between a CRM system, Billing system, and Order Management system, any of the systems can initiate a change, and then the change is propagated to the other two systems.

    N-way synchronizations are more complex than one-way synchronizations because multiple applications can change corresponding data concurrently.

Data Synchronization with webMethods

To perform data synchronization with webMethods, when a resource makes a data change, it notifies Integration Server by sending a document that describes the data change. If the source resource is using a webMethods adapter, the adapter can send an adapter notification that describes the data change.

The data from the source is typically in a layout or structure that is native to the source. You set up processing in Integration Server that maps values from the notification document to build a common‑structure document, referred to as a canonical document. Each target receives the canonical document, which they use to update the equivalent data on their systems.

The following diagram illustrates the basics of performing data synchronization with webMethods software.

Step Description
1 The source resource makes a data change.
2 Integration Server receives notification of the change on the source. For example, in the above illustration, an adapter checks for changes on the source. When the adapter recognizes a change on the source, it sends an adapter notification that contains information about the change that was made. The adapter might either publish the adapter notification or directly invoke a service passing it the adapter notification.

For more information about adapter notifications, see the guide for the specific adapter that you are using with a source resource.

3 A service that you create receives the notification of change on the source. For example, it receives the adapter notification. This service maps data from the change notification document to a canonical document. A canonical document is a common business document that contains the information that all target resources will require to incorporate data changes. The canonical document has a neutral structure among the resources. For more information, see Canonical Documents.

After forming the canonical document, the service publishes the canonical document. The targets subscribe to the canonical document.

4 On a target, the trigger that subscribes to the canonical document invokes a service that you create. This service maps data from the canonical document into a document that has a structure that is native to the target resource. The target resource uses the information in this document to make the equivalent change.
5 The target resource makes a data change that is equivalent to the change that the source initiated. If the target resource is using an adapter, an adapter service can be used to make the data change.

For more information about adapter services, see the guide for the specific adapter that you are using with a target resource.

Equivalent Data and Native IDs

As stated above, data synchronization keeps equivalent data across multiple systems consistent. Equivalent data in resources does not necessarily use the same layout or structure. The data structure is based on the requirements of the resource. The following example shows different data structures for customer data that a CRM system and a Billing system might use:

Structure of customer data in a CRM system Structure of customer data in a Billing system
Customer ID    
Customer Name    
       First    
       Surname    
Customer Address    
       Line1    
       Line2    
       City    
       State    
       ZipCode    
       Country    
Customer Payment Information    
Customer Account
Account ID    
Account Type    
Billing Account Owner    
       Last    
       First    
Billing Address    
       Number    
       Street    
       AptNumber    
       CityOrTown    
       State    
       Code    
       Country    
Billing Preferences

Data in an application contains a key value that uniquely identifies an object within the application. In the example above, the key value that uniquely identifies a customer within the CRM system is the Customer ID; similarly, the key value in the Billing system is the Account ID. The key value in a specific application is referred to as that application’s native ID. In other words, the native ID for the CRM system is the Customer ID, and the native ID for the Billing system is the Account ID.

Canonical Documents

Source resources send documents to notify other resources of data changes. You set up processing to map the data from these notification documents into a canonical document. A canonical document is a document with a neutral structure, and it encompasses all information that resources will require to incorporate data changes. Use of canonical documents:

  • Simplifies data synchronization between multiple resources by eliminating the need for every resource to understand the document structure of every other resource. Resources need only include logic for mapping to and from the canonical document. Without a canonical document, each resource needs to understand the document structures of the other resources. If a change is made to the document structure of one of the resources, logic for data synchronization would need to change in all resources.

    For example, consider keeping data synchronized between three resources: a CRM system, Billing system, and Order Management system. Because the systems map directly to and from each others native structures, a change in one resource’s structure affects all resources. If the address structure was changed for the CRM system, you would need to update data synchronization logic in all resources.

    When you use a canonical document, you limit the number of data synchronization logic changes that you need to make. Using the same example where the address structure changes for the CRM system, you would only need to update data synchronization logic in the CRM system.

  • Makes adding new resources to the data synchronization easier. With canonical documents, you only need to add data synchronization logic to the new resource to use the canonical document. Without a canonical document, you would need to update the data synchronization logic of all resources so they understand the structure of the newly added resource, and the new resource would need to understand the document structures of all the existing resources.

Structure of Canonical Documents and Canonical IDs

You define the structure of the canonical documents to include a superset of all the fields that are required to keep data synchronized between the resources. For more information, see Defining the Structure of the Canonical Document.

One field that you must include in the structure of the canonical document is a key value called the canonical ID. The canonical ID uniquely identifies the object to which the canonical document refers. In other words, the canonical ID in a canonical document serves the same purpose that the native ID does for a native document from one of your resources.

For example, in a CRM system document, the native ID might be a Customer ID that uniquely identifies a customer’s account in the CRM system. Similarly, a document from the Billing system might use an Account ID for the native ID to uniquely identify an account. When the CRM system document or Billing system documents get mapped to a canonical document, the document must contain a canonical ID that uniquely identifies the object (customer or account).

Integration Server provides key cross-referencing to allow you to create and manage the values of canonical IDs and their mappings to native IDs. The key cross-referencing tools that Integration Server provides are:

  • Cross-reference database component that you use to store relationships between canonical IDs and native IDs.
  • Built-in services that you use to manipulate the cross-reference table.

For more information, see Key Cross-Referencing and the Cross-Reference Table.

Key Cross-Referencing and the Cross-Reference Table

Key cross-referencing allows you to use a common key (i.e., the canonical ID) to build relationships between equivalent business objects from different resources. You build the relationships by mapping key values (i.e., the native IDs) from the resources to a common canonical ID. You maintain these relationships in the cross-reference database component (if using an external RDBMS) or the cross-reference table (if using the embedded internal database). For simplicity, in this chapter the term cross-reference table is used to encompass both. For information about configuring the cross-reference table, see Configuring Integration Server for Key Cross-Reference and Echo Suppression.

Note: The field names listed in the table below are not the actual column names used in the cross‑reference database component. They are the input variable names used by the key cross‑referencing built‑in services that correspond to the columns of the cross‑reference database component.

The cross-reference table includes the fields described in the following table:

Fields Description
appId A string that contains the identification of a resource, for example, “CRM System”. You assign this value.
objectId A string that contains the identification of the of the object that you want to keep synchronized, for example, “Account”. You assign this value.
nativeId The native ID of the object for the specific resource specified by appId. You obtain this value from the resource.
canonicalKey The canonical ID that is common to all resources for identifying the specific object.

You can assign this value, or you can allow a built-in service to generate the value for you.

For example, to synchronize data between a CRM system, Billing system, and Order Management system, you might have the following rows in the cross-reference table:

appId objectId nativeId canonicalKey
CRM system Account DAN0517 WM6308
Billing system Account 19970620 WM6308
Order Management Account acct0104 WM6308

How the Cross-Reference Table Is Used for Key Cross-Referencing

The following diagram illustrates how to use the cross-reference table for key cross‑referencing during data synchronization.

Step Description
1 As described in Data Synchronization with webMethods, when a source makes a data change, the source sends a document to notify other resources of the change. A service that you create receives this document. Your service builds the canonical document that describes the change.
2 When forming the canonical document, to determine the value to use for the canonical ID, your service invokes a built‑in service. This built-in service inspects the cross‑reference table to locate the row that contains the native ID from the source document. The built-in service then returns the corresponding canonical ID from the cross‑reference table. For more information about the built-in services you use, see Setting Up Key Cross-Referencing in the Source Integration Server.
3 A service that you create on the target receives the canonical document. When a target receives the canonical document, it needs to determine the native ID of the object that the change affects. To determine the native ID, your service on the target invokes a built‑in service. This built‑in service inspects the cross-reference table to locate the row that contains the canonical ID and the appropriate resource identified by the appId and object identified by objectId. The built‑in service then returns the corresponding native ID from the cross‑reference table. For more information about the built-in services you use, see Setting Up Key Cross-Referencing in the Target Integration Server.

Echo Suppression for N-Way Synchronizations

One other feature that Integration Server provides for data synchronization is echo suppression, which is also called latching. Echo suppression (or latching) is the process of preventing circular updating from occurring. Circular updating can occur when performing n-way synchronizations (data synchronizations where every resource can be a source and a target as well).

Circular updating occurs when the source subscribes to the canonical document that it publishes as illustrated in the diagram below.

Step Description
1 A data change occurs on a source, and the source resource sends a notification document.
2 The source Integration Server builds and publishes a canonical document.
3 Because the source is also a target, it (as well as all other targets) subscribes to the canonical document via a trigger. As a result, the source receives the canonical document it just published. Logic on the source Integration Server uses the canonical document to build an update document to send to the source. The source receives the update document and makes the data change again. Because the source made this data change, it once again acts as a source to notify targets of the data change. The process starts again with step 1.

In addition to the source immediately receiving the canonical that it formed, it can also receive the canonical document many more times because other targets build and publish the canonical document after making the data change that the source initiated. See below for an illustration of this circular updating.

Step Description
1 A data change occurs on a source, and the source sends a notification document.
2 The source Integration Server builds and publishes a canonical document.
3 A target receives the canonical document and makes the equivalent change.
4 Because the target made a data change, it sends a notification document for the data change.
5 The target Integration Server builds and publishes a canonical document.
6 The source receives the notification of the change that was made by the target and makes the change, again. This results in the process starting again with step 1.

To avoid the circular updating, Integration Server provides you with the following tools to perform echo suppression:

  • The isLatchClosed field in the cross-reference table that you use to keep track of whether a resource has already made a data change or not.
  • Built-in services that you use to manipulate the isLatchClosed field in the cross‑reference table to:
    • Determine the value of the isLatchClosed field, and
    • Set the value of the isLatchClosed column.

How the isLatchClosed Field Is Used for Echo Suppression

In addition to the appID, objectId, nativeId, and canonicalKey fields that are described in Key Cross-Referencing and the Cross-Reference Table, the cross‑reference table also includes the isLatchClosed field. The isLatchClosed field acts as a flag that indicates whether an object managed by a resource (e.g., account information) is allowed to be updated or whether a data change has already been made to the object and therefore should not be made again.

  • When the isLatchClosed field is false,this indicates that the latch is open and therefore updates can be made to the object.
  • When the isLatchClosed field is true, this indicates that the latch is closed and therefore updates should not be made to the object.

The following diagram illustrates how to use the isLatchClosed field for echo suppression during data synchronization.

Step Description
1 A data change occurs on a source, and the source sends a notification document.
2 A notification service that you create to notify targets of a data change invokes the pub.synchronization.latch:isLatchClosed built‑in service to determine whether the latch for the object is open or closed. Initially for the source, the latch for the object that was changed is open. This indicates that updates can be made to this object.

The object is identified in the cross-reference table by the following cross-reference table fields and the latch is considered open because isLatchClosed is false:

  appId objectId canonicalKey isLatchClosed
  CRM system Account WM6308 false
  Finding that the latch is currently open, the notification service builds the canonical document and publishes it. The notification service invokes the pub.synchronization.latch:closeLatch built-in service to close the latch. This sets the isLatchClosed field to true and indicates that updates cannot be made to this object and prevents a circular update. After the latch is closed, the cross‑reference table fields are as follows:
  appId objectId canonicalKey isLatchClosed
  CRM system Account WM6308 true
3 Because the source is also a target, it subscribes to the canonical document it just published. The trigger passes the canonical document to a service you create to update the resource when a data change occurs. This update service invokes the pub.synchronization.latch:isLatchClosed built‑in service to determine whether the latch is open or closed for the object.

Finding that the latch is currently closed, which indicates that the change has already been made, the update service does not make the update to the object. The update service invokes the pub.synchronization.latch:openLatch built‑in service to re‑open the latch to allow future updates to the object. After the latch is open, the cross‑reference table fields are as follows:

  appId objectId canonicalKey isLatchClosed
  CRM system Account WM6308 false
4 A service you create to update the target when a data change occurs receives the canonical document. This update service invokes the pub.synchronization.latch:isLatchClosed built‑in service to determine whether the latch is open or closed for the object. Initially, the cross‑reference table fields for the target object are as follows:
  appId objectId canonicalKey isLatchClosed
  Billing system Account WM6308 false
  Because initially the isLatchClosed column is set to false, this means the latch is open and updates can be made to this object. To make the update, the update service maps information from the canonical document to a native document for the target resource and sends the document to the target. The target resource uses this document to make the equivalent change.

The update service uses the pub.synchronization.latch:closeLatch built-in service to close the latch. This indicates that updates cannot be made to this object and prevents a circular update. After the latch is closed, the cross‑reference table fields are as follows:

  appId objectId canonicalKey isLatchClosed
  Billing system Account WM6308 true
5 Because the target made a data change, it sends notification of a change.
6 Because the target is also a source, when it receives notification of a data change, it attempts to notify other targets of the data change. A notification service that you create to notify targets of a data change invokes the pub.synchronization.latch:isLatchClosed built‑in service to determine whether the latch for the object is open or closed.

Finding that the latch is closed, which indicates that the change has already been made, the notification service does not build the canonical document. The notification service simply invokes the pub.synchronization.latch:openLatch built‑in service to re-open the latch. Because the latch is now open, future updates can be made to the object. After the latch is open, the cross‑reference table fields are as follows:

  appId objectId canonicalKey isLatchClosed
  Billing system Account WM6308 false

Tasks to Perform to Set Up Data Synchronization

The following table lists the tasks you need to perform to synchronize data changes to an object that is maintained in several of your resources (e.g., account information across all resources). Additionally, the table lists the section in this chapter where you can find more information about each task.

Task For more information, see...
Ensure the cross-reference table is set up. Defining How a Source Resource Sends Notification of a Data Change
Define publishable document type for the notification documents that each source sends when the object being synchronized is changed. Defining How a Source Resource Sends Notification of a Data Change
Define an publishable document type for the canonical document, which describes the data change for all target resources. Defining the Structure of the Canonical Document
Define logic on the source Integration Server to receive the source resource’s notification document, build the canonical document, and publish the canonical document. This includes the following tasks:
  • Create a trigger to subscribe to the source’s notification document. Note that you only need to create this trigger if the source publishes its notification document.
  • Create a service that builds the canonical document from the fields in the source’s notification document and publishes the canonical document to notify targets of the data change.
Setting Up Key Cross-Referencing in the Source Integration Server
Define logic on the target Integration Server that receives the canonical document and interacts with a target resource to make the equivalent change to the object on the target. This includes the following tasks:
  • Create a trigger that subscribes to the canonical document that the source Integration Server publishes.
  • Create an IS document type for the native document that the target Integration Server sends the target resource, so the target can make the equivalent change.
  • Create a service that builds the target native document from fields in the canonical document.
Setting Up Key Cross-Referencing in the Target Integration Server
If you are doing n-way synchronizations, add logic to perform echo suppression to the services you created for key cross‑referencing. For N-Way Synchronizations Add Echo Suppression to Services

Defining How a Source Resource Sends Notification of a Data Change

Before you create logic that receives a notification document from a source resource and builds the canonical document, you need to determine how the source resource is to notify the source Integration Server when a data change occurs.

The source resource notifies other resources of a data change by sending a document that describes the change. The type of document the source sends depends on whether you are:

  • Using a webMethods adapter with the source, or
  • Developing your own interaction with the source.

The following diagram highlights the part of data synchronization that this section addresses.

When Using an Adapter with the Source

When you use an adapter to manage the source resource, configure the adapter to send an adapter notification when a change occurs on the resource. For information about how to configure the adapter, see the documentation for the adapter.

If the adapter does not create an publishable document type for the adapter notification, use Software AG Designer to define an publishable document type that defines the structure of the adapter notification.

Based on the adapter, the adapter does one of the following to send the adapter notification:

  • Publishes the adapter notification. A trigger on the source Integration Server subscribes to this publishable document type. When the trigger receives a document that matches the publishable document type for the adapter notification, it invokes the trigger service that builds the canonical document.
  • Directly invokes the service that builds the canonical document. When the service is directly invoked, the adapter notification is sent to the service as input.

For more information about creating the service that builds the canonical document, see Setting Up Key Cross-Referencing in the Source Integration Server.

When Developing Your Own Interaction with the Source

When you develop your own logic to interact with the source resource, the logic should include sending a document when a data change occurs within the resource. You define the document fields that you require for the notification. Be sure to include a field for the native ID to identify the changed object on the source.

After determining the fields that you need in the source native document (i.e., the notification), use Software AG Designer to define an IS document type for the native document. The logic you create to interact with the source resource can do one of the following to send the source native document:

  • Publish the source native document. If your logic publishes the source’s native document, define a publishable document type for the source’s native document. A trigger on the source Integration Server subscribes to this publishable document type. When the trigger receives a document that matches the publishable document type for the source’s native document, it invokes the trigger service that builds the canonical document.
  • Directly invoke the service that builds the canonical document, When the service is directly invoked, the source’s native document is sent to the service as input. If your logic passes the native document to the service as input, the IS document type does not need to be publishable.

For more information about creating the service that your logic should invoke, see Setting Up Key Cross-Referencing in the Source Integration Server.

Defining the Structure of the Canonical Document

The following diagram highlights the part of data synchronization that uses the canonical document.

To define the structure for canonical documents, you include a superset of all the fields that are required to keep data synchronized between the resources. Additionally, you must include a field for the canonical ID.

The following table lists options for defining the structure of a canonical document:

Use a... Benefit
Standard format (e.g., cXML, CBL, RosettaNet) A standards committee has already decided the structure, and you can leverage their thought and effort.
Complete custom format You define a unique structure that you tailor for your organization. The document structure might be smaller, and therefore easier to maintain because it only contains the fields your enterprise requires. Also, the smaller size has a positive effect on performance.
Custom format based on a standard You define a unique structure by starting with a structure that a standards committee has defined. You can take advantage of the thought and effort already put into deciding the standards-based format. However, you can delete fields that your enterprise might not need and add additional fields that are specific to your enterprise.

After determining the fields that you need in the canonical document, use Software AG Designer to define an publishable document type for the canonical document. For more information about how to create publishable document types, see webMethods Service Development Help .

Setting Up Key Cross-Referencing in the Source Integration Server

The source resource sends a notification document to the source Integration Server when a data change occurs in the source resource. This section describes how to define the logic for the source Integration Server to:

  • Receive the notification document,
  • Use notification document to build the canonical document, and
  • Publish the canonical document.

You create a service to build and publish the canonical document. The logic to build the canonical document uses built-in services for key cross‑referencing, which are described in Built-In Services for Key Cross-Referencing. In this chapter, the service that builds the canonical document is referred to as a notification service.

You should implement key cross‑referencing for both one-way and n-way synchronizations.

Note: For an overview of key cross‑referencing, including the problem key cross‑referencing solves and how key cross‑referencing works, see Key Cross-Referencing and the Cross-Reference Table.

The following diagram highlights the part of data synchronization that this section addresses.

Built-In Services for Key Cross-Referencing

The following table lists the built‑services that webMethods provides for key cross‑referencing. The key cross‑referencing services are located in the pub.synchronization.xref folder. For more information about these services, see the pub.synchronization.xref:createXReference.

Service Description
createXReference Used by the source to assign a canonical ID and add a row to the cross-reference table to create a cross‑reference between the canonical ID and the source’s native ID. To assign the value for the canonical ID, you can either specify the value as input to the createXReference service or have the createXReference service generate the value.
insertXReference Used by a target to add a row to the cross‑reference table to add the target’s cross‑reference between an existing canonical ID (which the source added) and the target’s native ID.
getCanonicalKey Retrieves the value of the canonical ID from the cross‑reference table that corresponds to the native ID that you specify as input to the getCanonicalKey service.
getNativeId Retrieves the value of the native ID from the cross‑reference table that corresponds to the canonical ID that you specify as input to the getNativeId service.

Setting up the Source Integration Server

To set up key cross‑referencing in the source Integration Server:

  • Create a trigger to subscribe to the source resource’s notification document, if applicable. You only need to define a trigger that subscribes to the notification document if the source resource publishes the notification document (i.e., either an adapter notification or other native document). If the source directly passes the notification document to a service as input, you do not need to define a trigger. If you need to define a trigger, define the trigger that:
    • Subscribes to the publishable document type that defines the notification document (i.e., either an adapter notification or other native document).
    • Defines the trigger service to be the service that builds the canonical document from the notification document.

    For more information, see webMethods Service Development Help .

  • Create the trigger service that builds the canonical document and publishes the canonical document to propagate the data change to all target resources. You need to create a service that puts the data change information into a neutral format that all targets understand. The neutral format is the canonical document.

    The service builds the canonical document by mapping information from the notification document to the canonical document. To obtain the canonical ID for the canonical document, the service uses the built‑in key cross‑referencing services pub.synchronization.xref:getCanonicalKey and/or pub.synchronization.xref:createXReference, as shown in the sample logic below. After forming the canonical document, your service publishes the canonical document.

    Step Description
    1 Determine whether there is already a canonical ID. Invoke the pub.synchronization.xref:getCanonicalKey service to locate a row in the cross‑reference table for the source object. If the row already exists, a canonical ID already exists for the source object. Pass the getCanonicalKey service the following inputs that identify the source object:
      In this input variable... Specify...
      appId The identification of the application (e.g., CRM system).
      objectId The string that you assigned to identify the object (e.g., Account). This string is referred to as the object ID.
      nativeId The native ID from the notification document (e.g., adapter notification), which was received as input to your service.
      If the getCanonicalKey service finds a row in the cross‑reference table that matches the input information, it returns the value of the canonical ID in the canonicalKey output variable. If no row is found, the value of the canonicalKey output variable is blank (i.e., an empty string). For more information about the getCanonicalKey service, see the pub.synchronization.xref:getCanonicalKey.
    2 Split logic based on whether the canonical ID already exists. Use a BRANCH flow step to split the logic. Set the Switch property of the BRANCH flow step to canonicalKey.
    3 Build a sequence of steps to execute when the canonical ID does not already exist. Under the BRANCH flow step is a single sequence of steps that should be executed only if a canonical ID was not found. Note that the Label property for the SEQUENCE flow step is set to blank. At run time, the server matches the value of the canonicalKey variable to the Label field to determine whether to execute the sequence. Because the canonicalKey variable is set to blank (i.e., an empty string), the label field must also be blank.
    Important: Do not use $null for the Label property. An empty string is not considered a null.
    4 If there is no canonical ID, define one. If a row for the source object is not found in the cross‑reference table, there is no canonical ID for the source object. Define a canonical ID by adding a row to the cross‑reference table to cross‑reference the source native ID with a canonical ID. You add the row by invoking the pub.synchronization.xref:createXReference service. Pass the createXReference service the following:
      In this input variable... Specify...
      appId The identification of the application (e.g., CRM system).
      objectId The object type (e.g., Account).
      nativeId The native ID from the notification document (e.g., adapter notification), which was received as input to your service.
      canonicalKey (optional) The value you want to assign the canonical ID.
      If you do not specify a value for the canonicalKey input variable, the createXReference service generates a canonical ID for you. For more information about the createXReference service, see the pub.synchronization.xref:createXReference.
    5 Build the canonical document. Map fields from the notification document (e.g., adapter notification) to the fields of the canonical document. Make sure you map the canonical ID generated in the last step to the canonical ID field of the canonical document.

    The notification document has the structure that you previously defined with a the publishable document type. See Defining How a Source Resource Sends Notification of a Data Change. Similarly, the canonical document has the structure that you previously defined with a publishable document type. See Defining the Structure of the Canonical Document.

    Note: Although this sample logic shows only a single MAP flow step, you might need to use additional flow steps or possibly create a separate service to build the canonical document.
    6 Publish the canonical document. After the service has formed the canonical document, invoke the pub.publish:publish service to publish the canonical document to the messaging provider.

Setting Up Key Cross-Referencing in the Target Integration Server

The canonical document is published to the target Integration Servers. This section describes how to define the logic for a target Integration Server to:

  • Receive the canonical document.
  • Use the canonical document to build a document to inform the target resource of the data change. This document has a structure that is native to the target resource.
  • Send the native document to the target resource, so the target resource can make the equivalent data change.

You create a service to build the native document and send it to the target resource. The logic to build the native document uses built-in services for key cross‑referencing, which are described in Built-In Services for Key Cross-Referencing. In this chapter, the service that receives the canonical document and builds a native document is referred to as an update service.

The following diagram highlights the part of data synchronization that this section addresses.

To set up key cross‑referencing in the target Integration Server:

  • Create a trigger that subscribes to the canonical document that the source server publishes. On the target Integration Servers, define a trigger that:
    • Subscribes to the publishable document type that defines the canonical document.
    • Defines the trigger service to be the service that builds the builds a native document for the target resource.

    For more information, see webMethods Service Development Help .

  • Create an IS document type that defines the structure of the document that the target Integration Server needs to send to the target resource to notify it of a data change. For more information about how to create IS document types, see webMethods Service Development Help .
  • Create the trigger service that uses the canonical document to build the target native document and sends the native document to the target resource. The service receives the canonical document, which contains the description of the data change to make. However, typically the target resource will not understand the canonical document. Rather, the target resource requires a document in its own native format.

    The service can build the native document for the target resource by mapping information from the canonical document to the target resource’s native document format. Make sure you include the native ID in this document. To obtain the native ID, invoke the pub.synchronization.xref:getNativeId built‑in service. If the native ID is cross‑referenced with the canonical ID in the cross‑reference table, this service returns the native ID. If no cross‑reference has been set up for the object, you will need to determine the best way to obtain the native ID.

    After forming the native document, the trigger service interacts with the target resource to make the data change.

    Note: For a description of the built‑in services that webMethods provides for key cross‑referencing, see Built-In Services for Key Cross-Referencing.

The following shows sample logic for the update service. See the table after the diagram for more information.

Step Description
1 Obtain the native ID for the target object if there is an entry for the target object in the cross-reference table. Invoke the pub.synchronization.xref:getNativeId service to locate a row in the cross-reference table for the target object. If the row already exists, the row contains the native ID for the target object. Pass the getNativeId service the following inputs that identify the target object:
  In this input variable... Specify...
  appId The identification of the application (e.g., Billing system).
  objectId The object type (e.g., Account).
  canonicalKey The canonical ID from the canonical document, which was received as input to your service.
  If the getNativeId service finds a row that matches the input information, it returns the value of the native ID in the nativeId output variable. If no row is found, the value of the nativeId output variable is blank (i.e., an empty string). For more information about the getNativeId service, see the pub.synchronization.xref:getNativeId.
2 Split logic based on whether a native ID was obtained for the target resource. Use a BRANCH flow step to split the logic. Set the Switch property of the BRANCH flow step to nativeId, to indicate that you want to split logic based on the value of the nativeId pipeline variable.
3 Build a sequence of steps to execute when the native ID is not obtained. Under the BRANCH flow step is a single sequence of steps to perform only if a native ID was not found. Note that the Label property for the SEQUENCE flow step is set to blank. At run time, the server matches the value of the nativeID variable to the label field to determine whether to execute the sequence. Because the nativeId variable is set to blank (i.e., an empty string), the Label field must also be blank.
Important: Do not use $null for the Label property. An empty string is not considered null.
4 If no native ID was obtained, specify one. If a native ID was not found, add a row to the cross‑reference table for the target object to cross‑reference the target native ID with the canonical ID by invoking the pub.synchronization.xref:insertXReference service. Pass the insertXReference service:
  In this input variable... Specify...
  appId The identification of the application (e.g., Billing system).
  objectId The object type (e.g., Account).
  nativeId The native ID for the object in the target resource. You must determine what the native ID should be.
  canonicalKey The canonical ID from the canonical document, which was received as input to your service.
  For more information about the insertXReference service, see the pub.synchronization.xref:insertXReference.
5 Build the native document for the target resource. To build the native document, map fields from the canonical document to the fields of native document. Also map the native ID to the native document.

The canonical document has the structure that you previously defined with a publishable document type. See Defining the Structure of the Canonical Document. Similarly, the native document has the structure that you previously defined with an IS document type.

Note: Although this sample logic shows only a single MAP flow step, you might need to use additional flow steps or possibly create a separate service to build the native document for the target resource.
6 Invoke a service to send the native document to the target resource, so the target resource can make the equivalent change. Create a service that sends the native document to the target.

If you use an adapter with your target resource, you can use an adapter service to update the target resource. For more information about adapter services, see the documentation for your adapter.

For N-Way Synchronizations Add Echo Suppression to Services

When you use n-way synchronization, you need to include logic that performs echo suppression to the:

Echo suppression logic blocks circular updating of data changes from occurring. Echo suppression is not needed when you use one-way synchronization.

Note: For an overview of echo suppression, including information about how echo suppression solves the problem of circular updating, see Echo Suppression for N-Way Synchronizations.

Built-in Services for Echo Suppression

The following table lists the built‑services that webMethods provides for echo suppression. The echo suppression services are located in the pub.synchronization.latch folder.

Service Description
closeLatch Closes the latch for the specified canonical ID, application ID (appId), and object type (objectId). To close the latch, the isLatchClosed field of the cross‑reference table is set to true. A closed latch indicates that the resource described in the cross‑reference row cannot be acted upon until the latch is open using the openLatch service.
isLatchClosed Determines whether the latch is open or closed for the specified canonical ID, application ID (appId), and object type (objectId). To check the status of the latch, the service uses the isLatchClosed field of the cross‑reference table. The output provides a status of true (the latch is closed) or false (the latch is open).
openLatch Opens the latch for the specified canonical ID, application ID (appId), and object type (objectId). To open the latch, the isLatchClosed field of the cross‑reference table is set to false. An open latch indicates that the resource described in the cross‑reference row can be acted upon.

Adding Echo Suppression to Notification Services

The echo suppression logic in a notification service determines whether a latch is open or closed before it attempts to build and publish the canonical document.

  • If the latch is open, the resource is the source of the data change. In this case, the notification service on the source Integration Server builds the canonical document and publishes it. The notification service should include logic that closes the latch to prevent a circular update.
  • If the latch is closed, the resource has already made the data change. In this case, the notification service does not need to build the canonical document to notify resources about the data change because the notification service on the source Integration Server has already done so. The notification service should simply re‑open the latch and terminate processing.

The following diagram highlights the part of data synchronization that this section addresses.

Incorporating Echo Suppression Logic into a Notification Service

The following shows the sample notification service with echo suppression logic added to it. The sample notification service was presented in Setting Up Key Cross-Referencing in the Source Integration Server along with a description of its flow steps, which are unnumbered in the sample below. The numbered flow steps in the sample below are the flow steps added for echo suppression. For more information about the numbered flow steps, see the table after the diagram.

Step Description
1 Determine whether the latch is open or closed for the changed object. Invoke the pub.synchronization.latch:isLatchClosed service to locate a row in the cross‑reference table for the object that has changed and for which you want to send notification. Pass the isLatchClosed service the following inputs that identify the object:
  In this input variable... Specify...
  appId The identification of the application (e.g., Billing system).
  objectId The object type (e.g., Account).
  canonicalKey The canonical ID.
  The isLatchClosed service uses the isLatchClosed field from the matching row to determine whether the latch is open or closed. If the isLatchClosed field is ‘false’, the latch is open, and the isLatchClosed service returns ‘false’ in the isLatchClosed output variable. If the isLatchClosed field is ‘true’, the latch is closed, and the service returns ‘true’. For more information about the isLatchClosed service, see pub.synchronization.latch:isLatchClosed.
2 Split logic based on whether the latch is open or closed. Use a BRANCH flow step to split the logic. Set the Switch property of the BRANCH to isLatchClosed, to indicate that you want to split logic based on the value of the isLatchClosed pipeline variable.
3 Build a sequence of steps to execute when the latch is open. Because the Label property for the SEQUENCE flow step is set to false, this sequence of operations is executed when the isLatchClosed variable is false, meaning the latch is open. When the latch is open, the target resources have not yet been notified of the data change. This sequence of steps builds and publishes the canonical document.
4 Close the latch. When the latch is open, the first step is to close the latch. By closing the latch before publishing the canonical document, you remove any chance that Integration Server will receive and act on the published canonical document.

To close the latch, invoke the pub.synchronization.latch:closeLatch service. Pass the closeLatch service the same input variables that were passed to the pub.sychronization.latch:isLatchClosed service in step 1 above. For more information about the closeLatch service, see pub.synchronization.latch:closeLatch.

5 Build a sequence of steps to execute when the latch is closed. Because the Label property for the SEQUENCE flow operation is set to true, this sequence of steps is executed when the isLatchClosed variable is true, meaning the latch is closed. When the latch is closed, notification of the data change has already been published. As a result, the notification service does not need to build or publish the canonical document. This sequence of steps simply re-opens the latch.
6 Re-open the latch. Re-open the latch to reset the latch for future data changes. To re-open the latch, invoke the pub.synchronization.latch:openLatch service. Pass the openLatch service the same input variables that were passed to the pub.sychronization.latch:isLatchClosed service in step 1 above. For more information about the openLatch service, see the pub.synchronization.latch:openLatch..
Important: If multiple resources will make changes to the same object simultaneously or near simultaneously, echo suppression cannot guarantee successful updating. If you expect simultaneous or near simultaneous updates, you must take additional steps:
  1. When defining the structure of a canonical document, include a tracking field that identifies the source of the change to the canonical document structure.
  2. In the notification service include a filter or BRANCH to test on the source field to determine whether to send the notification.

Adding Echo Suppression to Update Trigger Services

The update trigger service receives the canonical document that describes a data change. The echo suppression logic in an update service determines whether a latch is open or closed before it attempts to use the information in the canonical document to update a resource with the data change.

  • If the latch is open, the data change has not yet been made to the resource. In this case, the update service builds and sends the native document that informs the target resource of the data change. The update service closes the latch to prevent a circular update.
  • If the latch is closed, the resource was the source of the data change and has already made the data change. In this case, the update service does not need build and send the native document. The update service should simply re‑open the latch and terminate processing.

The following diagram highlights the part of data synchronization that this section addresses.

Incorporating Echo Suppression Logic into an Update Service

The following shows the sample update service with echo suppression logic added to it. The sample update service was presented in Setting Up Key Cross-Referencing in the Target Integration Server along with a description of its flow steps, which are unnumbered in the sample below. The numbered flow steps in the sample below are the flow steps added for echo suppression. For more information about the numbered flow steps, see the table after the diagram.

Step Description
1 Determine whether the latch is open or closed for the changed object. Invoke the pub.synchronization.latch:isLatchClosed service to locate a row in the cross‑reference table for the changed object. Pass the isLatchClosed service the following inputs that identify the object:
  In this input variable... Specify...
  appId The identification of the application (e.g., Billing system).
  objectId The object type (e.g., Account).
  canonicalKey The canonical ID.
  The isLatchClosed service uses the isLatchClosed field from the matching row to determine whether the latch is open or closed. If the isLatchClosed field is ‘false’, the latch is open, and the isLatchClosed service returns ‘false’ in the isLatchClosed output variable. If the isLatchClosed field is ‘true’, the latch is closed, and the service returns ‘true’. For more information about the isLatchClosed service, see the pub.synchronization.latch:isLatchClosed..
2 Split logic based on whether the latch is open or closed. Use a BRANCH flow step to split the logic. Set the Switch property of the BRANCH to isLatchClosed, to indicate that you want to split logic based on the value of the isLatchClosed pipeline variable.
3 Build a sequence of steps to execute when the latch is open. Because the Label property for the SEQUENCE flow step is set to false, this sequence of operations is executed when the isLatchClosed variable is false, meaning the latch is open. When the latch is open, the target resource has not yet made the equivalent data change. This sequence of steps builds and sends a native document that the target resource uses to make the equivalent change.
4 Close the latch. When the latch is open, close the latch before sending the native document to the target resource. For n-way synchronizations because a target is also a source, when the resource receives and makes the equivalent data change, the resource then sends notification of a data change. By closing the latch before sending the native document to the target resource, you remove any chance that Integration Server will receive and act on a notification document being sent by the resource.

To close the latch, invoke the pub.synchronization.latch:closeLatch service. Pass the closeLatch service the same input variables that were passed to the pub.sychronization.latch:isLatchClosed service in step 1 above. For more information about the closeLatch service, see the pub.synchronization.latch:closeLatch..

5 Build a sequence of steps to execute when the latch is closed. Because the Label property for the SEQUENCE flow step is set to true, this sequence of steps is executed when the isLatchClosed variable is true, meaning the latch is closed. When the latch is closed, the resource has already made the equivalent data change. As a result, the update service does not need to build or send a native document to the target resource.
6 Re-open the latch. Re-open the latch to reset the latch for future data changes. To re-open the latch, invoke the pub.synchronization.latch:openLatch service. Pass the openLatch service the same input variables that were passed to the pub.sychronization.latch:isLatchClosed service in step 1 above. For more information about the openLatch service, see the pub.synchronization.latch:openLatch..
Important: If multiple resources will make changes to the same object simultaneously or near simultaneously, echo suppression cannot guarantee successful updating. If you expect simultaneous or near simultaneous updates, you must take additional steps:
  1. When defining the structure of a canonical document, include a tracking field that identifies the source of the change to the canonical document structure.
  2. In the update service include a filter or BRANCH to test on the source field to determine whether to update the object.