From ac0431d2afcf29f96d09f807f552b9f00ea85f9b Mon Sep 17 00:00:00 2001 From: Kartik kalaghatgi Date: Wed, 26 Jul 2023 19:35:10 +0530 Subject: [PATCH] CAMEL-19650: Camel Kafka doesn't honor 'workerPool' configuration (#10827) * CAMEL-19650: Camel Kafka doesn't honor 'workerPool' configuration Camel kafka component when provided with custom worker pool is ignored and still creates a new pool, this is fixed with check added to use custom worker pool if provided. * CAMEL-19650: Camel Kafka doesn't honor 'workerPool' configuration Fixing checkstyle issue --- .../apache/camel/component/kafka/KafkaProducer.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/components/camel-kafka/src/main/java/org/apache/camel/component/kafka/KafkaProducer.java b/components/camel-kafka/src/main/java/org/apache/camel/component/kafka/KafkaProducer.java index 017645e364c45..cfb56bdf38f6e 100644 --- a/components/camel-kafka/src/main/java/org/apache/camel/component/kafka/KafkaProducer.java +++ b/components/camel-kafka/src/main/java/org/apache/camel/component/kafka/KafkaProducer.java @@ -119,9 +119,15 @@ protected void doStart() throws Exception { // if we are in asynchronous mode we need a worker pool if (!configuration.isSynchronous() && workerPool == null) { - workerPool = endpoint.createProducerExecutor(); - // we create a thread pool so we should also shut it down - shutdownWorkerPool = true; + // If custom worker pool is provided, then use it, else create a new one. + if (configuration.getWorkerPool() != null) { + workerPool = configuration.getWorkerPool(); + shutdownWorkerPool = false; + } else { + workerPool = endpoint.createProducerExecutor(); + // we create a thread pool so we should also shut it down + shutdownWorkerPool = true; + } } }