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
https://camel.apache.org/staging/
We would very much like to receive any feedback on the new site, please join the discussion on the Camel user mailing list.
YAMLYAML 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 from("activemq:My.Queue") .marshal().yaml() .to("mqseries:Another.Queue"); // lets turn Object messages into yaml then send to MQSeries from("activemq:My.Queue") .marshal().yaml(YAMLLibrary.SnakeYAML) .to("mqseries:Another.Queue"); Using YAML in Spring DSLWhen using Data Format in Spring DSL you need to declare the data formats first. This is done in the DataFormats XML tag. <dataFormats> <!-- 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"/> </dataFormats> And then you can refer to this id in the route: <route> <from uri="direct:back"/> <unmarshal ref="snake"/> <to uri="mock:reverse"/> </route>
Options for SnakeYAML Data Format
Dependencies for SnakeYAMLTo 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). <dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-snakeyaml</artifactId> <version>${camel-version}</version> </dependency>
|