5.2. @EndpointInject と @Produce
プレーン Camel または SpringBoot 上の Camel から @org.apache.camel.EndpointInject
と @org.apache.camel.Produce
を使用することに慣れている場合は、これらを Quarkus でも引き続き使用できます。
次のユースケースは、org.apache.camel.quarkus:camel-quarkus-core
によってサポートされています。
import jakarta.enterprise.context.ApplicationScoped; import org.apache.camel.EndpointInject; import org.apache.camel.FluentProducerTemplate; import org.apache.camel.Produce; import org.apache.camel.ProducerTemplate; @ApplicationScoped class MyBean { @EndpointInject("direct:myDirect1") ProducerTemplate producerTemplate; @EndpointInject("direct:myDirect2") FluentProducerTemplate fluentProducerTemplate; @EndpointInject("direct:myDirect3") DirectEndpoint directEndpoint; @Produce("direct:myDirect4") ProducerTemplate produceProducer; @Produce("direct:myDirect5") FluentProducerTemplate produceProducerFluent; }
direct:myDirect*
の代わりに、他の Camel プロデューサーエンドポイント URI を使用できます。
警告
@EndpointInject
と @Produce
は、セッターメソッドではサポートされていません。#2579 を参照してください。
次のユースケースは org.apache.camel.quarkus:camel-quarkus-bean
でサポートされています。
import jakarta.enterprise.context.ApplicationScoped; import org.apache.camel.Produce; @ApplicationScoped class MyProduceBean { public interface ProduceInterface { String sayHello(String name); } @Produce("direct:myDirect6") ProduceInterface produceInterface; void doSomething() { produceInterface.sayHello("Kermit") } }