Class AbstractEthosChangeNotificationSubscription

    • Field Detail

      • ethosChangeNotificationService

        protected EthosChangeNotificationService ethosChangeNotificationService
        The service used for retrieving ChangeNotifications.
    • Constructor Detail

      • AbstractEthosChangeNotificationSubscription

        public AbstractEthosChangeNotificationSubscription​(Flow.Publisher publisher,
                                                           Flow.Subscriber subscriber,
                                                           EthosChangeNotificationService ethosChangeNotificationService,
                                                           long pollingInterval,
                                                           TimeUnit pollingIntervalTimeUnit)
        Constructs this subscription with the given params.
        Parameters:
        publisher - The publisher for this subscription.
        subscriber - The subscriber subscribing to this subscription. Should be a client application subscriber that extends AbstractEthosChangeNotificationSubscriber.
        ethosChangeNotificationService - Service for retrieving ChangeNotifications.
        pollingInterval - The polling time interval between polling attempts.
        pollingIntervalTimeUnit - The time unit for the polling interval.
        Throws:
        IllegalArgumentException - Thrown if the given ethosChangeNotificationService is null.
    • Method Detail

      • request

        public void request​(long numNotifications)
        Intended to be used internally by the SDK.

        Runs the ChangeNotification subscription process for receiving both individual ChangeNotifications and ChangeNotification lists. Uses the scheduledExecutorService to schedule a thread to run the process for this subscription according to the polling interval and pollingIntervalTimeUnit. Has an initial delay of 1 second before running.

        Specified by:
        request in interface Flow.Subscription
        Overrides:
        request in class AbstractEthosNotificationSubscription
        Parameters:
        numNotifications - Indicates the number of ChangeNotifications to retrieve at a single time from Ethos Integration per poll request. Must be between 1 and 1000.
      • cancel

        public void cancel()
        Submits a cancellation request to cancel the current subscription process. The process should stop running so that no further notifications are received after the current poll attempt completes.
        Specified by:
        cancel in interface Flow.Subscription
        Overrides:
        cancel in class AbstractEthosNotificationSubscription
      • processRequest

        protected void processRequest​(int numNotifications)
        Intended to be used internally by the SDK.

        Processes the current polling attempt run by the scheduledExecutorService. This method will retrieve ALL notifications from Ethos Integration using the number of notifications (numNotifications) per request made via the ethosChangeNotificationService. If there are many notifications to retrieve, this method could take a while to run, especially if the numNotifications is a small number.

        Parameters:
        numNotifications - The number of notifications to retrieve at a time from Ethos Integration for each notification request made. Must be between 1 and 1000.
      • processChangeNotifications

        protected abstract void processChangeNotifications​(List<ChangeNotification> cnList)
        Intended to be used internally by the SDK.

        Subclass implementations should override this method.

        Parameters:
        cnList - The list of ChangeNotifications to propagate.
      • getChangeNotifications

        protected List<ChangeNotification> getChangeNotifications​(int numNotifications)
                                                           throws IOException
        Intended to be used internally by the SDK.

        Gets ChangeNotifications from Ethos Integration using the ethosChangeNotificationService. The default number of notifications will be retrieved if numNotifications is < 0.

        Parameters:
        numNotifications - The number of notifications to retrieve from Ethos Integration.
        Returns:
        a List of ChangeNotifications, or an empty list of none are found.
        Throws:
        IOException - Propagated if thrown from the ethosChangeNotificationService.
      • processCancellation

        protected void processCancellation()
        Intended to be used internally by the SDK.

        Processes the cancellation of this subscription. Unsubscribes the subscriber from the publisher, cancels future processing of the thread running this subscription, and shuts down the scheduledExecutorService running the schedule for the thread running this subscription process.