This week, we’ll study the Format Indicator pattern.
When do I use this pattern?
When integrating multiple systems together, a common data model is agreed upon. However, this common data model is not exempt from the universal law that is
The only constant is change. – Heraclitus of Ephesus
Okay, now we know that even common data model changes. However, when the common data model changes, all the participants may not require the change or may not accommodate the change right away. In this case, the format of data being used in a given message can be indicated. The target system can consume a message based on the format indicator.
Format Indicator Pattern
In Enterprise Integration Patterns book, Gregor Hohpe and Bobby Wolf mention 3 ways to indicate the format of the message:
- Version Number
- Foreign Key
- Format Document
As the name suggests, a version of the message format is mentioned along with the message. For example, in XML, XML Declaration specifies version number.
Here, version attribute specifies that the XML that follows uses 1.0 version. Now, the receiver must store the data format with version 1.0 and use it to understand the message and process it.
Another way of indicating format is to declare definitions in a Document Type Definition file and specify the DTD file in the Document Type Declaration.
<!DOCTYPE greeting SYSTEM "hello.dtd">
Here, the greeting tag must follow rules specified inside hello.dtd file.
The last way to indicate format is to specify the format directly inside the Document Type Declaration.
<!DOCTYPE greeting [
<!ELEMENT greeting (#PCDATA)>
Here, ‘greeting’ is the root node of the XML and the type of greeting node is parseable character data. W3Schools have a nice example of XML DTD: XML DTD on W3Schools.
As the format of the data is indicated within the message itself, the receiver needs to understand the format of data dynamically and process the message accordingly. This also means that message size will be larger than when the Version Number or Foreign Key is used.
How do I use Format Indicator in CPI?
Unfortunately, I have never used this pattern in CPI or in Process Orchestration. Have you used this pattern? Comment your experience of Format Indicator pattern below or write a blog showcasing how you applied the Format Indicator pattern.
Format Indicator pattern is a coping mechanism against the inevitable that is Change. Indicating the format of the message in the message enables target systems to process the message whether it uses old format or new format.
Hope this helps,
P.S.: This also completes the blogs for Message Construction patterns, next week we’ll start with Message Routing patterns, the first one being Pipes-and-Filters.
About the Author
More Content by Bhalchandra Wadekar