346.7. Java DSL

このように、ThriftDataFormat インスタンスを作成し、それを Camel DataFormat マーシャリングおよびアンマーシャリング API に渡すことができます。

   ThriftDataFormat format = new ThriftDataFormat(new Work());

   from("direct:in").marshal(format);
   from("direct:back").unmarshal(format).to("mock:reverse");

または、非整列化デフォルトインスタンスまたはデフォルトインスタンスクラス名を次のように渡す DSL thrift() を使用します。

   // You don't need to specify the default instance for the thrift marshaling
   from("direct:marshal").marshal().thrift();
   from("direct:unmarshalA").unmarshal()
       .thrift("org.apache.camel.dataformat.thrift.generated.Work")
       .to("mock:reverse");

   from("direct:unmarshalB").unmarshal().thrift(new Work()).to("mock:reverse");