Java 如何自定义预定义的Camel组件?

Java 如何自定义预定义的Camel组件?,java,spring-boot,apache-camel,Java,Spring Boot,Apache Camel,我在camel-Kafka-starter依赖项中使用了一个Kafka组件。 在这篇文章中,我被推荐使用“定制器”。如何在spring boot应用程序中使用它?解决方案是在spring boot配置文件中定义组件,如下所示: @Configuration public class MyConfig { @Bean ComponentCustomizer<KafkaComponent> myCustomizer(){ return new Compone

我在
camel-Kafka-starter
依赖项中使用了一个Kafka组件。
在这篇文章中,我被推荐使用“定制器”。如何在spring boot应用程序中使用它?

解决方案是在spring boot配置文件中定义组件,如下所示:

@Configuration
public class MyConfig {

   @Bean 
   ComponentCustomizer<KafkaComponent> myCustomizer(){
       return new ComponentCustomizer<KafkaComponent>() {

           @Override
           public void customize(KafkaComponent component) {
               //KafkaConfiguration config = new KafkaConfiguration(); //optional extra config

               component.setAllowManualCommit(true);
               component.setBrokers(brokers);
               component.setWorkerPool(workerPool); 
           };
       };
    }

   @Component
   public class route extends RouteBuilder {

        @Override
        public void configure() throws Exception {
           from("file://target/inbox")
           .to("direct:kafka_in")

           from("direct:kafka_in")
           .log(LoggingLevel.WARN, "Generated : $simple{body}")
           .to("kafka:topic2")
           .log("[P-kafka_in] regular Producer");

       } 
    }
}

然后,该组件将流入该定制器并在那里进行处理。

因此,您为您的问题写了一个答案???@TrishulSinghChoudhary@Amongalen谢谢!!只是想确定一下,这是一个真实的答案,而不是问题的一部分吗?
camel.component.kafka.configuration.retries=1234567
camel.component.kafka.configuration.request-required-acks=all
camel.component.kafka.configuration.enable-idempotence=true