Skip to content

Commit

Permalink
changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Andreas Mautsch committed Jul 6, 2024
1 parent 0346dd5 commit 3890ddf
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
package org.goafabric.eventdispatcher.producer;

import org.goafabric.eventdispatcher.service.extensions.TenantContext;

import java.util.Map;

public record EventData (
Map<String, String> tenantInfos,
String referenceId,
Object payload
) {}
) {
public EventData {
TenantContext.setContext(tenantInfos);
}
}

0 comments on commit 3890ddf

Please sign in to comment.