346.6. 例

以下は、ホストとポートのパラメーターを使用した単純な同期メソッドの呼び出しです。

from("direct:thrift-calculate")
.to("thrift://localhost:1101/org.apache.camel.component.thrift.generated.Calculator?method=calculate&synchronous=true");

以下は、XML DSL 設定の単純な同期メソッド呼び出しです。

<route>
    <from uri="direct:thrift-add" />
    <to uri="thrift://localhost:1101/org.apache.camel.component.thrift.generated.Calculator?method=add&synchronous=true"/>
</route>

非同期通信による Thrift サービスコンシューマー

from("thrift://localhost:1101/org.apache.camel.component.thrift.generated.Calculator")
.to("direct:thrift-service");

thrift-maven-plugin を使用して .thrift ファイルの Java コード生成を自動化することは可能ですが、開始する前に、オペレーティングシステムの thrift コンパイラーバイナリーディストリビューションが実行中のホストに存在している必要があります。