Let's create a listener NotificationListener class that will be used to listen to messages on the Kafka notification topic and send email and SMS notifications to the customer:
@Componentpublic class NotificationListener {@StreamListener(NotificationStreams.INPUT)public void sendMailNotification(@Payload Notification notification) {System.out.println("Sent notification to email: "+notification.getEmail()+" Message: "+notification.getMessage());}@StreamListener(NotificationStreams.INPUT)public void sendSMSNotification(@Payload Notification notification) {System.out.println("Notified with SMS to mobile: "+notification.getMobile()+" Message: "+notification.getMessage());}}
The NotificationListener class has two methods— ...