Several applications are communicating via Messages that follow an agreed upon data format, perhaps an enterprise-wide Canonical Data Model. However, that format may need to change over time.
How can a message’s data format be designed to allow for possible future changes?
Design a data format that includes a Format Indicator, so that the message specifies what format it is using.
The format indicator enables the sender to tell the receiver the format of the message. This way, a receiver expecting several possible formats knows which one a message is using and therefore how to interpret the message’s contents.
There are three main alternatives for implementing a format indicator:
- Version Number – A number or string that that uniquely identifies the format. Both the sender and receiver must agree on which format is designated by a particular indicator.
- Foreign Key – A unique ID—such as a filename, a database row key, a home primary key, or an Internet URL—that specifies a format document. The sender and receiver must agree on the mapping of keys to documents, and the format of the schema document.
- Format Document – A schema that describes the data format. The schema document does not have to be retrieved via a foreign key or inferred from a version number, it is embedded in the message. The sender and the receiver must agree on the format of the schema.
... Read the entire pattern in the book Enterprise Integration Patterns
Related patterns: