From 0d0a900dafe129b28b38d0d0daac80ea72cd2527 Mon Sep 17 00:00:00 2001 From: Nicolas Filotto Date: Wed, 26 Jul 2023 16:20:10 +0200 Subject: [PATCH] CAMEL-19650: Camel Kafka doesn't honor 'workerPool' configuration (#10827) (#10842) * 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 Co-authored-by: Kartik kalaghatgi --- .../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; + } } }