Writing a custom data marshaller
Camel supports a pluggable ability to translate messages to and from binary and text formats through a feature called Data Formats. Data Formats are an implementation of the Message Translator Enterprise Integration Pattern.
Camel's libraries include a number of Data Formats, such as JAXB, JSON, CSV, HL7, Base64, Crypto, Gzip, and so on. This recipe describes how to write your own Data Format for instances when you need more than what Camel provides out of the box.
This recipe will show you how to create your own Data Format implementation that can be easily shared across your Camel routes.
Getting ready
The Java code for this recipe is located in the org.camelcookbook.extend.dataformat
package. The Spring XML files are located under src/main/resources/META-INF/spring
and prefixed with dataformat
.
How to do it...
There are two main steps for creating and using a custom Data Format. First, you need to create a Java class that implements the DataFormat
interface...