Skip to content
This repository has been archived by the owner on Nov 4, 2024. It is now read-only.

Commit

Permalink
Add logging to Kafka events service for demo purposes
Browse files Browse the repository at this point in the history
Signed-off-by: Jade Carino <[email protected]>
  • Loading branch information
jadecarino committed Jul 2, 2024
1 parent a41e75c commit 6c673b8
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
}

Expand All @@ -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<String, IEventProducer> entry : producers.entrySet()) {
entry.getValue().close();
}
Expand Down

0 comments on commit 6c673b8

Please sign in to comment.