Code: Select all
public List getUserDonationHistory(String userId) {
// 1. Make a request to the payment-service from which to get the donation-history
producerService.requestUserDonationHistory(userId);
return null;
}
< /code>
Der KafkaproDucerService < /p>
public void requestUserDonationHistory(String userId) {
log.info("Requesting the donation-history for the user with the ID: {}", userId);
kafkaTemplate.send("request-donation-history", userId);
}
Code: Select all
@KafkaListener(topics = "request-donation-history", groupId = "groupId")
public void getDonationHistoryRequest(String userId) {
log.info("Got a donationHistoryRequest. Raw userId: {}", userId);
Long parsedUserId = Long.parseLong(gson.fromJson(userId, String.class));
log.info("Parsed userId: {}", parsedUserId);
producerService.sendUserDonationHistory(parsedUserId);
}