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.
- Loading branch information
Erling Jahr
committed
Nov 20, 2023
1 parent
2d27084
commit 8e7991d
Showing
4 changed files
with
48 additions
and
7 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
40 changes: 40 additions & 0 deletions
40
src/main/java/no/fintlabs/user/UserEntityProducerService.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,40 @@ | ||
package no.fintlabs.user; | ||
|
||
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; | ||
|
||
@Service | ||
@Slf4j | ||
public class UserEntityProducerService { | ||
private final EntityProducer<User> entityProducer; | ||
private final EntityTopicNameParameters entityTopicNameParameters; | ||
|
||
public UserEntityProducerService(EntityProducerFactory entityProducerFactory, | ||
EntityTopicService entityTopicService) { | ||
entityProducer = entityProducerFactory.createProducer(User.class); | ||
entityTopicNameParameters = EntityTopicNameParameters | ||
.builder() | ||
.resource("kontrolluser") | ||
.build(); | ||
entityTopicService.ensureTopic(entityTopicNameParameters,0); | ||
} | ||
|
||
public void publish(User user){ | ||
String key = user.getResourceId(); | ||
entityProducer.send( | ||
EntityProducerRecord.<User>builder() | ||
.topicNameParameters(entityTopicNameParameters) | ||
.key(key) | ||
.value(user) | ||
.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
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