diff --git a/src/main/java/org/goafabric/eventdispatcher/consumer/kafka/CalendarConsumer.java b/src/main/java/org/goafabric/eventdispatcher/consumer/kafka/CalendarConsumer.java index aadc071..6917f73 100644 --- a/src/main/java/org/goafabric/eventdispatcher/consumer/kafka/CalendarConsumer.java +++ b/src/main/java/org/goafabric/eventdispatcher/consumer/kafka/CalendarConsumer.java @@ -1,7 +1,6 @@ package org.goafabric.eventdispatcher.consumer.kafka; import org.goafabric.eventdispatcher.producer.EventData; -import org.goafabric.eventdispatcher.service.extensions.TenantContext; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.kafka.annotation.KafkaListener; @@ -18,7 +17,6 @@ public class CalendarConsumer { @KafkaListener(groupId = CONSUMER_NAME, topics = "patient") @KafkaListener(groupId = CONSUMER_NAME, topics = "practitioner") public void processKafka(@Header(KafkaHeaders.RECEIVED_KEY) String key, EventData eventData) { - TenantContext.setContext(eventData.tenantInfos()); process(key, eventData); } diff --git a/src/main/java/org/goafabric/eventdispatcher/consumer/kafka/LoggerConsumer.java b/src/main/java/org/goafabric/eventdispatcher/consumer/kafka/LoggerConsumer.java index fbc1630..d68c645 100644 --- a/src/main/java/org/goafabric/eventdispatcher/consumer/kafka/LoggerConsumer.java +++ b/src/main/java/org/goafabric/eventdispatcher/consumer/kafka/LoggerConsumer.java @@ -17,11 +17,11 @@ public class LoggerConsumer { @KafkaListener(groupId = CONSUMER_NAME, topicPattern = ".*") public void processKafka(@Header(KafkaHeaders.RECEIVED_KEY) String key, EventData eventData) { - TenantContext.setContext(eventData.tenantInfos()); process(key, eventData); } private void process(String key, EventData eventData) { + log.info("tenantinfo: {}", TenantContext.getAdapterHeaderMap()); log.info("logging event: {}; id = {}", key, eventData.referenceId()); } diff --git a/src/main/java/org/goafabric/eventdispatcher/consumer/nats/NatsCalendarConsumer.java b/src/main/java/org/goafabric/eventdispatcher/consumer/nats/NatsCalendarConsumer.java index d365d6e..8874653 100644 --- a/src/main/java/org/goafabric/eventdispatcher/consumer/nats/NatsCalendarConsumer.java +++ b/src/main/java/org/goafabric/eventdispatcher/consumer/nats/NatsCalendarConsumer.java @@ -19,7 +19,6 @@ public NatsCalendarConsumer(NatsSubscription natsSubscription) { } private void process(String key, EventData eventData) { - TenantContext.setContext(eventData.tenantInfos()); switch (key) { case "patient.create" -> createPatient(eventData.referenceId()); case "patient.update" -> updatePatient(eventData.referenceId()); diff --git a/src/main/java/org/goafabric/eventdispatcher/consumer/nats/NatsLoggerConsumer.java b/src/main/java/org/goafabric/eventdispatcher/consumer/nats/NatsLoggerConsumer.java index c31cb33..8e955e8 100644 --- a/src/main/java/org/goafabric/eventdispatcher/consumer/nats/NatsLoggerConsumer.java +++ b/src/main/java/org/goafabric/eventdispatcher/consumer/nats/NatsLoggerConsumer.java @@ -18,7 +18,7 @@ public NatsLoggerConsumer(NatsSubscription natsSubscription) { } private void process(String key, EventData eventData) { - TenantContext.setContext(eventData.tenantInfos()); + log.info("tenantinfo: {}", TenantContext.getAdapterHeaderMap()); log.info("logging event: {}; id = {}", key, eventData.referenceId()); //msg.ack(); } diff --git a/src/main/java/org/goafabric/eventdispatcher/producer/EventData.java b/src/main/java/org/goafabric/eventdispatcher/producer/EventData.java index 2509f8c..2e95f68 100644 --- a/src/main/java/org/goafabric/eventdispatcher/producer/EventData.java +++ b/src/main/java/org/goafabric/eventdispatcher/producer/EventData.java @@ -1,9 +1,15 @@ package org.goafabric.eventdispatcher.producer; +import org.goafabric.eventdispatcher.service.extensions.TenantContext; + import java.util.Map; public record EventData ( Map tenantInfos, String referenceId, Object payload -) {} +) { + public EventData { + TenantContext.setContext(tenantInfos); + } +}