Class KafkaNotificationPublisher
java.lang.Object
com.reallifedeveloper.common.infrastructure.messaging.KafkaNotificationPublisher
- All Implemented Interfaces:
NotificationPublisher
An implementation of the
NotificationPublisher interface which uses Apache Kafka.- Author:
- RealLifeDeveloper
-
Constructor Summary
ConstructorsConstructorDescriptionKafkaNotificationPublisher(org.springframework.kafka.core.KafkaTemplate<String, String> kafkaTemplate, ObjectSerializer<String> objectSerializer) Creates a newKafkaNotificationPublisherwhich uses the givenObjectSerializerto serialize notifications, and the givenKafkaTemplateto send them to Kafka. -
Method Summary
Modifier and TypeMethodDescriptionvoidpublish(List<Notification> notifications, String publicationChannel) Publishes a number of notifications to the given publication channel.
-
Constructor Details
-
KafkaNotificationPublisher
public KafkaNotificationPublisher(org.springframework.kafka.core.KafkaTemplate<String, String> kafkaTemplate, ObjectSerializer<String> objectSerializer) Creates a newKafkaNotificationPublisherwhich uses the givenObjectSerializerto serialize notifications, and the givenKafkaTemplateto send them to Kafka.- Parameters:
kafkaTemplate- theKafkaTemplateto useobjectSerializer- theObjectSerializerto use
-
-
Method Details
-
publish
Description copied from interface:NotificationPublisherPublishes a number of notifications to the given publication channel.- Specified by:
publishin interfaceNotificationPublisher- Parameters:
notifications- a list ofNotificationsto publishpublicationChannel- the name of the publication channel- Throws:
IOException- if publishing failed
-