generated from FINTLabs/fint-spring-boot-template-project
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FKS-706 publishing applicationCategory to Kafka
- Loading branch information
Erling Jahr
committed
Apr 23, 2024
1 parent
3a17b84
commit 81164ef
Showing
3 changed files
with
54 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
src/main/java/no/fintlabs/fintResourceServices/ApplicationCategoryProduserService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package no.fintlabs.fintResourceServices; | ||
|
||
|
||
import lombok.extern.slf4j.Slf4j; | ||
import no.fintlabs.kafka.entity.EntityProducer; | ||
import no.fintlabs.kafka.entity.EntityProducerFactory; | ||
import no.fintlabs.kafka.entity.EntityProducerRecord; | ||
import no.fintlabs.kafka.entity.topic.EntityTopicNameParameters; | ||
import no.fintlabs.kafka.entity.topic.EntityTopicService; | ||
import org.springframework.stereotype.Service; | ||
|
||
import java.util.Map; | ||
|
||
@Service | ||
@Slf4j | ||
public class ApplicationCategoryProduserService { | ||
private final EntityProducer entityProducer; | ||
private final EntityTopicNameParameters entityTopicNameParameters; | ||
|
||
|
||
public ApplicationCategoryProduserService( | ||
EntityProducerFactory entityProducerFactory, | ||
EntityTopicService entityTopicService) { | ||
|
||
entityProducer = entityProducerFactory.createProducer(String.class); | ||
entityTopicNameParameters = EntityTopicNameParameters | ||
.builder() | ||
.resource("applicationcategory") | ||
.build(); | ||
entityTopicService.ensureTopic(entityTopicNameParameters,0); | ||
} | ||
|
||
public void publish(Map<String,String> appCategory){ | ||
appCategory.forEach((key,value) -> { | ||
log.info("{} :: {}", key, value); | ||
entityProducer.send( | ||
EntityProducerRecord.<String>builder() | ||
.topicNameParameters(entityTopicNameParameters) | ||
.key(key) | ||
.value(value) | ||
.build() | ||
|
||
); | ||
}); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters