346.7. Java DSL

您可以使用 create ThriftDataFormat 实例并将它传递到 Camel DataFormat marshal 和 unmarshal API。

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

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

或者,使用 DSL thrift ()传递 unmarshal default 实例或默认实例类名称,如下所示。

   // 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");