345.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 컴파일러 바이너리 배포를 시작하기 전에 실행 중인 호스트에 있어야 합니다.