Service used to write to Kafka

Let's see the following service class that is responsible for writing to Kafka in our application:

@Servicepublic class NotificationService {  private final NotificationStreams notificationStreams; public NotificationService(NotificationStreams notificationStreams) {  super();  this.notificationStreams = notificationStreams; }  public void sendNotification(final Notification notification) {  MessageChannel messageChannel = notificationStreams.notifyTo();  messageChannel.send(MessageBuilder.withPayload(notification)    .setHeader(MessageHeaders.CONTENT_TYPE, MimeTypeUtils.APPLICATION_JSON)    .build()); }}

In the preceding service class, the sentNotification() method uses an injected NotificationStreams object to send ...

Get Mastering Spring Boot 2.0 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.