From 6c673b8bc6f583042d62bb3ad293c987a5a98271 Mon Sep 17 00:00:00 2001 From: Jade Carino Date: Tue, 2 Jul 2024 17:05:58 +0100 Subject: [PATCH 1/2] Add logging to Kafka events service for demo purposes Signed-off-by: Jade Carino --- .../events/kafka/internal/KafkaEventsService.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/galasa-extensions-parent/dev.galasa.events.kafka/src/main/java/dev/galasa/events/kafka/internal/KafkaEventsService.java b/galasa-extensions-parent/dev.galasa.events.kafka/src/main/java/dev/galasa/events/kafka/internal/KafkaEventsService.java index 35b63c68..e022105b 100644 --- a/galasa-extensions-parent/dev.galasa.events.kafka/src/main/java/dev/galasa/events/kafka/internal/KafkaEventsService.java +++ b/galasa-extensions-parent/dev.galasa.events.kafka/src/main/java/dev/galasa/events/kafka/internal/KafkaEventsService.java @@ -15,8 +15,13 @@ import java.util.HashMap; import java.util.Properties; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + public class KafkaEventsService implements IEventsService { + private final Log logger = LogFactory.getLog(getClass()); + private IConfigurationPropertyStoreService cps; private IEventProducerFactory producerFactory; @@ -47,11 +52,14 @@ public void produceEvent(String topic, IEvent event) throws EventsException { producer = producers.get(topic); if (producer == null) { + logger.info("Creating a new producer as one does not exist for the topic " + topic); Properties properties = this.producerFactory.createProducerConfig(cps, topic); producer = this.producerFactory.createProducer(properties, topic); producers.put(topic, producer); + } else { + logger.info("Using the cached producer for the topic " + topic); } } @@ -62,7 +70,7 @@ public void produceEvent(String topic, IEvent event) throws EventsException { @Override public void shutdown() { - // Shut down all cached EventProducers + logger.info("Shutting down all cached producers"); for (Map.Entry entry : producers.entrySet()) { entry.getValue().close(); } From 1a5f72999f0930ad99f63a7ef9e1d72a6eb09deb Mon Sep 17 00:00:00 2001 From: Jade Carino Date: Wed, 3 Jul 2024 11:30:14 +0100 Subject: [PATCH 2/2] Add commons logging to bundle file for kafka Signed-off-by: Jade Carino --- galasa-extensions-parent/dev.galasa.events.kafka/bnd.bnd | 1 + 1 file changed, 1 insertion(+) diff --git a/galasa-extensions-parent/dev.galasa.events.kafka/bnd.bnd b/galasa-extensions-parent/dev.galasa.events.kafka/bnd.bnd index d9130100..6096fe7b 100644 --- a/galasa-extensions-parent/dev.galasa.events.kafka/bnd.bnd +++ b/galasa-extensions-parent/dev.galasa.events.kafka/bnd.bnd @@ -5,6 +5,7 @@ Bundle-License: https://www.eclipse.org/legal/epl-2.0 Export-Package: dev.galasa.events.kafka* Import-Package: \ dev.galasa.framework.spi,\ + org.apache.commons.logging,\ org.apache.kafka.clients,\ org.apache.kafka.clients.admin,\ org.apache.kafka.clients.consumer,\