이 콘텐츠는 선택한 언어로 제공되지 않습니다.
Chapter 166. JiBX DataFormat
Available as of Camel version 2.6
JiBX is a Data Format which uses the JiBX library to marshal and unmarshal Java objects to and from XML.
// lets turn Object messages into XML then send to MQSeries from("activemq:My.Queue"). marshal().jibx(). to("mqseries:Another.Queue");
// lets turn Object messages into XML then send to MQSeries
from("activemq:My.Queue").
marshal().jibx().
to("mqseries:Another.Queue");
Please note that marshaling process can recognize the message type at the runtime. However while unmarshaling message from XML we need to specify target class explicitly.
// lets turn XML into PurchaseOrder message from("mqseries:Another.Queue"). unmarshal().jibx(PurchaseOrder.class). to("activemq:My.Queue");
// lets turn XML into PurchaseOrder message
from("mqseries:Another.Queue").
unmarshal().jibx(PurchaseOrder.class).
to("activemq:My.Queue");
166.1. Options 링크 복사링크가 클립보드에 복사되었습니다!
The JiBX dataformat supports 3 options which are listed below.
Name | Default | Java Type | Description |
---|---|---|---|
unmarshallClass |
| Class name to use when unmarshalling from XML to Java. | |
bindingName |
| To use a custom binding factory | |
contentTypeHeader |
|
| Whether the data format should set the Content-Type header with the type from the data format if the data format is capable of doing so. For example application/xml for data formats marshalling to XML, or application/json for data formats marshalling to JSon etc. |
166.2. JiBX Spring DSL 링크 복사링크가 클립보드에 복사되었습니다!
JiBX data format is also supported by Camel Spring DSL.
166.3. Dependencies 링크 복사링크가 클립보드에 복사되었습니다!
To use JiBX in your camel routes you need to add the a dependency on camel-jibx 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-jibx</artifactId> <version>2.6.0</version> </dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-jibx</artifactId>
<version>2.6.0</version>
</dependency>