Normalizing messages into a common XML format
This recipe will show you a strategy for normalizing input that arrives in many different data formats (CSV, JSON, and XML) into a single canonical XML format. The strategy shown here also allows you to handle unknown input formats.
This strategy uses the Normalizer EIP, which is a Content Based Router EIP (see the Content Based Routing recipe in Chapter 2, Message Routing) combined with Data Format translators. It detects the incoming message format, and performs one or more steps needed to transform the message to the canonical format. After the Content Based Router, all processing steps can now operate assuming the message is in canonical format.
Note
It the following example, a subtle point to note is that we are transforming the message into an object graph of JAXB objects—a parsed version of the XML message. See the Transforming from Java to XML with JAXB recipe for more details.
Getting ready
The Java code for this recipe is located in the...