Since we're on a major migration process of this website, some component documents here are out of sync right now. In the meantime you may want to look at the early version of the new website
We would very much like to receive any feedback on the new site, please join the discussion on the Camel user mailing list.


YAML is a Data Format to marshal and unmarshal Java objects to and from YAML.

For YAML to object marshalling, Camel provides integration with three popular YAML libraries:

Every library requires adding the special camel component (see "Dependency..." paragraphs further down). By default Camel uses the SnakeYAML library.

Using YAML data format with the SnakeYAML library

// lets turn Object messages into yaml then send to MQSeries
// lets turn Object messages into yaml then send to MQSeries

Using YAML in Spring DSL

When using Data Format in Spring DSL you need to declare the data formats first. This is done in the DataFormats XML tag.

            <!-- here we define a YAML data format with the id snak and that it should use the TestPojo as the class type when
                 doing unmarshal. The unmarshalTypeName is optional, if not provided Camel will use a Object.class as the type -->
            <yaml id="snake" library="SnakeYAML" unmarshalTypeName="org.apache.camel.component.yaml.model.TestPojo"/>

And then you can refer to this id in the route:

            <from uri="direct:back"/>
            <unmarshal ref="snake"/>
            <to uri="mock:reverse"/>


Options for SnakeYAML Data Format








Class of the object to be created
ClassLoadernullThe classloader to use to instantiate objects
StringnullA reference to an
org.yaml.snakeyaml.constructor.BaseConstructor instance in the registry
StringnullA reference to an
org.yaml.snakeyaml.representer.Representer instance in the registry
StringnullA reference to an
org.yaml.snakeyaml.DumperOptions instance in the
StringnullA reference to an
org.yaml.snakeyaml.resolver.Resolver instance in the registry
 Booleantrue To use CamelContext's  
ApplicationContextClassLoader if no custom class loader is set and
ApplicationContextClassLoader is provided
Force the emitter to produce a pretty YAML document when using the flow style


Dependencies for SnakeYAML

To use YAML in your camel routes you need to add the a dependency on camel-snakeyaml which implements this data format.

If you use maven you could just add the following to your pom.xml, substituting the version number for the latest & greatest release (see the download page for the latest versions).




© 2004-2015 The Apache Software Foundation.
Apache Camel, Camel, Apache, the Apache feather logo, and the Apache Camel project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.
Graphic Design By Hiram