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

Commit

Permalink
Merge branch 'main' into iss1729-revoke-tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
eamansour authored Jul 3, 2024
2 parents 609fc7d + 43f2eb9 commit 62441b1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions galasa-extensions-parent/dev.galasa.events.kafka/bnd.bnd
Original file line number Diff line number Diff line change
Expand Up @@ -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,\
Expand Down
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 62441b1

Please sign in to comment.