347.7. Java DSL
您可以使用创建 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 默认实例或默认实例类名称,如下所示。
// 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");