Previous – Normalizer | Index | Next – Message Endpoint
This week, we'll study a message transformation pattern known as
Canonical Data Model.
When do I use this pattern?
Message Translator is used when participants don't use the same data format. If multiple systems use different formats to represent a single entity,
Normalizer can be used to map the message into a common data format. The common data format is also known as Canonical Data Model.
The advantages of using the canonical data model are:
- Simplicity by the reduction in the number of Message Translators
- Abstract design thinking
Simplicity
Without the Canonical Data Model, a
Message Translator would be required between each system for a given entity. For example, if 4 systems are communicating with each other about Customer, then 2 translators between each system add up to 12 translators. On the other hand, the use of the Canonical Data Model reduces the number of translators to 8 as 2 translators exist for each system to translate the message to and from the Canonical Data Model.
Without the Canonical Data Model
With Canonical Data Model
Abstract Design Thinking
As each system translates its internal data format to a common data format, the solution can be designed using the common data format instead of system-specific data formats, thereby improving the quality of the design.
Canonical Data Model in CPI
In CPI, implementing the Canonical Data Model means that you'll use
Message Translators to translate the message to and from the Canonical Data Model. For example, if customer information needs to be synchronised between ECC, Salesforce, and Hybris, the canonical data model could be used. Each system will have a set of message mappings.
ECC
From Canonical Data Model
To Canonical Data Model
Salesforce
Now, if Salesforce system is added, all we need to do is add two flows to translate the message from Salesforce Customer to Canonical Data Model's Customer and vice versa.
From Canonical Data Model
To Canonical Data Model
Hybris
Similarly, for Hybris, all we need is to add mappings to and from the Canonical Data Model. Please note that I am using the HTTP protocol to connect with Hybris for demonstration purpose only.
From Canonical Data Model
To Canonical Data Model
Conclusion
Canonical Data Model is a way to design the data in a generic format independent of any of the participating systems. It reduces the number of translations required and promotes abstract design thinking. In CPI, it can simply be implemented using Message Mappings.
References/Further Readings
Hope this helps,
Bala
Previous – Normalizer | Index | Next – Message Endpoint