Class AbstractEthosChangeNotificationSubscription
- java.lang.Object
-
- com.ellucian.ethos.integration.notification.AbstractEthosNotificationSubscription
-
- com.ellucian.ethos.integration.notification.AbstractEthosChangeNotificationSubscription
-
- All Implemented Interfaces:
Flow.Subscription
- Direct Known Subclasses:
EthosChangeNotificationListSubscription
,EthosChangeNotificationSubscription
public abstract class AbstractEthosChangeNotificationSubscription extends AbstractEthosNotificationSubscription
Abstract class containing the processing logic common for both ChangeNotification and ChangeNotification list processing. Contains theEthosChangeNotificationService
used for retrieving ChangeNotifications. Extends theAbstractEthosNotificationSubscription
which is the primary base class for notification subscriptions.- Since:
- 0.2.0
- Author:
- David Kumar
-
-
Field Summary
Fields Modifier and Type Field Description protected EthosChangeNotificationService
ethosChangeNotificationService
The service used for retrieving ChangeNotifications.-
Fields inherited from class com.ellucian.ethos.integration.notification.AbstractEthosNotificationSubscription
cancelSubscription, pollingInterval, pollingIntervalTimeUnit, publisher, scheduledExecutorService, scheduledFuture, subscriber
-
-
Constructor Summary
Constructors Constructor Description AbstractEthosChangeNotificationSubscription(Flow.Publisher publisher, Flow.Subscriber subscriber, EthosChangeNotificationService ethosChangeNotificationService, long pollingInterval, TimeUnit pollingIntervalTimeUnit)
Constructs this subscription with the given params.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
cancel()
Submits a cancellation request to cancel the current subscription process.protected List<ChangeNotification>
getChangeNotifications(int numNotifications)
Intended to be used internally by the SDK.protected void
processCancellation()
Intended to be used internally by the SDK.protected abstract void
processChangeNotifications(List<ChangeNotification> cnList)
Intended to be used internally by the SDK.protected void
processRequest(int numNotifications)
Intended to be used internally by the SDK.void
request(long numNotifications)
Intended to be used internally by the SDK.-
Methods inherited from class com.ellucian.ethos.integration.notification.AbstractEthosNotificationSubscription
isRunning
-
-
-
-
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 interfaceFlow.Subscription
- Overrides:
request
in classAbstractEthosNotificationSubscription
- 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 interfaceFlow.Subscription
- Overrides:
cancel
in classAbstractEthosNotificationSubscription
-
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.
-
-