Class NotificationService

java.lang.Object
com.reallifedeveloper.common.application.notification.NotificationService

public class NotificationService extends Object
An application service to work with NotificationLogs.
Author:
RealLifeDeveloper
  • Constructor Details

    • NotificationService

      public NotificationService(EventStore eventStore, PublishedMessageTrackerRepository messageTrackerRepository, NotificationPublisher notificationPublisher)
      Creates a new NotificationService that uses the given components.
      Parameters:
      eventStore - an event store for finding stored domain events
      messageTrackerRepository - a repository for keeping track of the last notification published
      notificationPublisher - a publisher of notifications to external systems
      Throws:
      IllegalArgumentException - if any argument is null
  • Method Details

    • currentNotificationLog

      @Transactional(readOnly=true) public NotificationLog currentNotificationLog(int batchSize)
      Gives a NotificationLog containing the most recent Notifications.
      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 archived NotificationLog.
      Parameters:
      notificationLogId - represents the first and last Notification in the log
      Returns:
      an archived NotificationLog
    • publishNotifications

      @Transactional public void publishNotifications(String publicationChannel) throws IOException
      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 protected final void finalize() throws Throwable
      Deprecated.
      Make finalize method final to avoid "Finalizer attacks" and corresponding SpotBugs warning (CT_CONSTRUCTOR_THROW).
      Overrides:
      finalize in class Object
      Throws:
      Throwable
      See Also: