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 newKafkaNotificationPublisher
which uses the givenObjectSerializer
to serialize notifications, and the givenKafkaTemplate
to send them to Kafka. -
Method Summary
Modifier and TypeMethodDescriptionvoid
publish
(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 newKafkaNotificationPublisher
which uses the givenObjectSerializer
to serialize notifications, and the givenKafkaTemplate
to send them to Kafka.- Parameters:
kafkaTemplate
- theKafkaTemplate
to useobjectSerializer
- theObjectSerializer
to use
-
-
Method Details
-
publish
Description copied from interface:NotificationPublisher
Publishes a number of notifications to the given publication channel.- Specified by:
publish
in interfaceNotificationPublisher
- Parameters:
notifications
- a list ofNotifications
to publishpublicationChannel
- the name of the publication channel- Throws:
IOException
- if publishing failed
-