Created
November 18, 2021 21:44
-
-
Save aytekin/f0e545249b255b640ea48a57779e52ef to your computer and use it in GitHub Desktop.
reactor-kafka
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
@Service | |
@Slf4j | |
@AllArgsConstructor | |
public class UserService { | |
private final KafkaProducer kafkaProducer; | |
private static final String USER_TOPIC = "user-create"; | |
public Mono<String> userCreate(Mono<UserDto> username){ | |
return username.flatMap(name -> | |
kafkaProducer.kafkaSender() | |
.send(USER_TOPIC, name.getUsername()) | |
.doOnNext(voidSenderResult -> log.info("{} sent to {} topic", name.getUsername(), USER_TOPIC)) | |
.doOnNext(voidSenderResult -> log.info("{}", voidSenderResult.recordMetadata())) | |
.thenReturn("It was sent successfully") | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment