Class NotificationService
java.lang.Object
com.reallifedeveloper.common.application.notification.NotificationService
An application service to work with
NotificationLogs
.- Author:
- RealLifeDeveloper
-
Constructor Summary
ConstructorsConstructorDescriptionNotificationService
(EventStore eventStore, PublishedMessageTrackerRepository messageTrackerRepository, NotificationPublisher notificationPublisher) Creates a newNotificationService
that uses the given components. -
Method Summary
Modifier and TypeMethodDescriptioncurrentNotificationLog
(int batchSize) Gives aNotificationLog
containing the most recentNotifications
.protected final void
finalize()
Deprecated.notificationLog
(NotificationLogId notificationLogId) Gives an archivedNotificationLog
.void
publishNotifications
(String publicationChannel) Publishes notifications about all events that have occurred since the last publication to the given publication channel.
-
Constructor Details
-
NotificationService
public NotificationService(EventStore eventStore, PublishedMessageTrackerRepository messageTrackerRepository, NotificationPublisher notificationPublisher) Creates a newNotificationService
that uses the given components.- Parameters:
eventStore
- an event store for finding stored domain eventsmessageTrackerRepository
- a repository for keeping track of the last notification publishednotificationPublisher
- a publisher of notifications to external systems- Throws:
IllegalArgumentException
- if any argument isnull
-
-
Method Details
-
currentNotificationLog
Gives aNotificationLog
containing the most recentNotifications
.- Parameters:
batchSize
- the maximum number of notifications in the notification log- Returns:
- a notification log with the most recent notifications
-
notificationLog
@Transactional(readOnly=true) public NotificationLog notificationLog(NotificationLogId notificationLogId) Gives an archivedNotificationLog
.- Parameters:
notificationLogId
- represents the first and lastNotification
in the log- Returns:
- an archived
NotificationLog
-
publishNotifications
Publishes notifications about all events that have occurred since the last publication to the given publication channel.- Parameters:
publicationChannel
- the name of the publication channel to publish notifications on- Throws:
IOException
- if publishing failed
-
finalize
Deprecated.Make finalize method final to avoid "Finalizer attacks" and corresponding SpotBugs warning (CT_CONSTRUCTOR_THROW).
-