Class AbstractEthosNotificationSubscription
- java.lang.Object
-
- com.ellucian.ethos.integration.notification.AbstractEthosNotificationSubscription
-
- All Implemented Interfaces:
Flow.Subscription
- Direct Known Subclasses:
AbstractEthosChangeNotificationSubscription
public abstract class AbstractEthosNotificationSubscription extends Object implements Flow.Subscription
An abstract super class for Ethos subscriptions containing the publisher, subscriber, and the threading capabilities used by subscription subclasses to run those subscription processes.Subscriptions will run indefinitely until canceled. The
cancel()
method must be called to stop the subscription from running.Implements the
Flow.Subscription
interface.- Since:
- 0.2.0
- Author:
- David Kumar
-
-
Field Summary
Fields Modifier and Type Field Description protected AtomicBoolean
cancelSubscription
Used to manage cancellation requests for cancelling the thread running this subscription.protected long
pollingInterval
The amount of time to wait between polls.protected TimeUnit
pollingIntervalTimeUnit
The time unit for the polling interval.protected Flow.Publisher
publisher
The publisher of this subscription.protected ScheduledExecutorService
scheduledExecutorService
Runs the thread for this subscription on a polling interval schedule.protected ScheduledFuture
scheduledFuture
Assigned by the scheduledExecutorService when it schedules the subscription process to run.protected Flow.Subscriber
subscriber
The subscriber subscribing to this subscription.
-
Constructor Summary
Constructors Constructor Description AbstractEthosNotificationSubscription(Flow.Publisher publisher, Flow.Subscriber subscriber, long pollingInterval, TimeUnit pollingIntervalTimeUnit)
Super constructor which must be called by subclasses supplying the given params.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
cancel()
Sets the cancellation flag to true, thereby requesting that the subscription stop running after the current polling operation completes.boolean
isRunning()
Indicates if this subscription is still running, or not.void
request(long numNotifications)
Intended to be used internally by the SDK.
-
-
-
Field Detail
-
publisher
protected Flow.Publisher publisher
The publisher of this subscription.
-
subscriber
protected Flow.Subscriber subscriber
The subscriber subscribing to this subscription.
-
cancelSubscription
protected AtomicBoolean cancelSubscription
Used to manage cancellation requests for cancelling the thread running this subscription.
-
scheduledExecutorService
protected ScheduledExecutorService scheduledExecutorService
Runs the thread for this subscription on a polling interval schedule.
-
scheduledFuture
protected ScheduledFuture scheduledFuture
Assigned by the scheduledExecutorService when it schedules the subscription process to run.
-
pollingInterval
protected long pollingInterval
The amount of time to wait between polls. A single poll will process all notifications from Ethos Integration. Subsequent polls will then process further notifications as they are available.
-
pollingIntervalTimeUnit
protected TimeUnit pollingIntervalTimeUnit
The time unit for the polling interval. Commonly specified by the publisher as TimeUnit.SECONDS.
-
-
Constructor Detail
-
AbstractEthosNotificationSubscription
public AbstractEthosNotificationSubscription(Flow.Publisher publisher, Flow.Subscriber subscriber, long pollingInterval, TimeUnit pollingIntervalTimeUnit)
Super constructor which must be called by subclasses supplying the given params. If the given pollingIntervalTimeUnit is null, it defaults to TimeUnit.SECONDS.- Parameters:
publisher
- The publisher for this subscription.subscriber
- The subscriber subscribing to this subscription.pollingInterval
- The polling interval between poll attempts.pollingIntervalTimeUnit
- The time unit for polling intervals.- Throws:
IllegalArgumentException
- Thrown if the given publisher or subscriber is null.
-
-
Method Detail
-
request
public void request(long numNotifications)
Intended to be used internally by the SDK.Should be overridden by subscription subclasses in the SDK.
- Specified by:
request
in interfaceFlow.Subscription
- Parameters:
numNotifications
- Indicates some number of notifications to process.
-
cancel
public void cancel()
Sets the cancellation flag to true, thereby requesting that the subscription stop running after the current polling operation completes. Subscriptions will run indefinitely, so this method must be called to stop them from running.- Specified by:
cancel
in interfaceFlow.Subscription
-
isRunning
public boolean isRunning()
Indicates if this subscription is still running, or not.- Returns:
- true if this subscription is running, in which case a subscriber would be subscribed to it and be receiving notifications (if any are retrieved), false if this subscription has been canceled.
-
-