使用JAXB序列化对象到Xml,并将Xml转换成对象。
<camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
<dataFormats>
<jaxb id="jaxb" contextPath="camelinaction"/>
</dataFormats>
<route>
<from uri="direct:order"/>
<marshal ref="jaxb"/>
<to uri="activemq:queue:order"/>
</route>
<route>
<from uri="activemq:queue:order"/>
<unmarshal ref="jaxb"/>
<to uri="direct:doSomething"/>
</route>
</camelContext>
org.apace.camel.spi.DataFormat包含两个方法:
marshal:—封送处理消息转换为另一种形式,例如:封装java对象到 XML , CSV , EDI , HL7 ,或者其它知名的格式。
unmarshal:—执行相反的操作,它将知名的格式数据转换成信息(对象)。
marshal与unmarshal之间的关系: