public class SubscriptionManager extends Object
NodeManager which it uses to locate the nodes.| Modifier and Type | Field and Description |
|---|---|
protected List<SubscriptionManagerListener> |
listeners |
protected NodeManagerTable |
nodeManagerTable |
protected SessionManager |
sessionManager |
| Constructor and Description |
|---|
SubscriptionManager(SessionManager sessionManager,
NodeManagerTable nodeManagerTable) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
acknowledge(ServiceContext serviceContext,
PublishRequest request,
PublishResponse response) |
protected void |
acknowledgeSubscriptions(ServiceContext serviceContext,
SubscriptionAcknowledgement[] acks,
StatusCode[] results,
DiagnosticInfo[] diagnostics) |
void |
addListener(SubscriptionManagerListener listener)
Add a new SubscriptionManagerListener.
|
protected SubscriptionBase |
addSubscription(ServiceContext serviceContext,
CreateSubscriptionRequest request)
Add a new subscription.
|
protected void |
addTriggeringLink(Subscription s,
MonitoredItemBase triggeringItem,
UnsignedInteger linkToAdd) |
protected NumericRange |
checkIndexRangeForMonitoredItem(String indexRange,
UnsignedInteger attributeId) |
protected void |
checkSession(ServiceContext serviceContext,
Subscription subscription) |
protected void |
close() |
protected MonitoredDataItem |
createMonitoredDataItem(ServiceContext serviceContext,
Subscription subscription,
MonitoredItemCreateRequest itemToCreate,
TimestampsToReturn timestampsToReturn,
MonitoringFilter filter) |
protected MonitoredItem |
createMonitoredEventItem(ServiceContext serviceContext,
Subscription subscription,
MonitoredItemCreateRequest itemToCreate,
EventFilter eventFilter) |
protected MonitoredItem |
createMonitoredItem(ServiceContext serviceContext,
Subscription subscription,
TimestampsToReturn timestampsToReturn,
MonitoredItemCreateRequest itemToCreate) |
protected Subscription |
createSubscription(SubscriptionManager subscriptionManager,
UnsignedInteger subscriptionId,
Boolean publishingEnabled,
double revisedPublishingInterval,
UnsignedInteger revisedLifetimeCount,
UnsignedInteger revisedMaxKeepAliveCount,
UnsignedInteger maxNotificationsPerPublish,
UnsignedByte priority)
This method can be overridden to use subtyped
Subscription. |
protected MonitoredItemBase |
deleteMonitoredItem(ServiceContext serviceContext,
Subscription subscription,
UnsignedInteger itemId) |
int |
getMaxMonitoredItemsPerSubscription()
Returns maximum number of MonitoredItems allowed in a Subscription.
|
int |
getMaxNotificationsPerPublish()
The limit for the maximum number of notifications parameter which is defined per subscription.
|
double |
getMaxPublishingInterval() |
int |
getMaxPublishRequestCount() |
int |
getMaxRetransmissionQueueSize()
The maximum number of notification messages to keep in the retransmit queue, which is used to
enable Republish calls from the client.
|
double |
getMaxSamplingInterval() |
int |
getMaxSubscriptionCount()
Maximum number of concurrent subscriptions per session.
|
double |
getMinPublishingInterval() |
double |
getMinSamplingInterval() |
UnsignedInteger |
getNextSubscriptionId()
Returns the SubscriptionId to be used when Clients make Subscriptions.
|
protected Subscription |
getNextSubscriptionToPublish(ServiceContext serviceContext,
long timeoutHint)
Find the next subscription from the publish queue
|
NodeManagerTable |
getNodeManagerTable() |
protected BlockingQueue<SubscriptionBase> |
getPublishQueue(Session session) |
SessionManager |
getSessionManager() |
Subscription |
getSubscription(UnsignedInteger subscriptionId)
Find the subscription by a subscriptionId
|
int |
getSubscriptionCount()
Number of managed subscriptions.
|
Collection<Subscription> |
getSubscriptions()
Get the current
Subscription(s) in the server. |
boolean |
hasListener(SubscriptionManagerListener listener)
Check if the manager already has the specified listener.
|
boolean |
isImmediatePublishing()
Whether immediate publishing is enabled.
|
boolean |
isRunning() |
boolean |
isTrackModelChanges()
|
protected MonitoredItem |
modifyMonitoredItem(ServiceContext serviceContext,
Subscription subscription,
MonitoredItemModifyRequest request,
TimestampsToReturn timestampsToReturn,
MonitoringParameters params) |
protected SubscriptionBase |
modifySubscription(ServiceContext serviceContext,
ModifySubscriptionRequest request) |
protected UnsignedInteger |
nextSubscriptionId()
Find the next Subscription ID.
|
protected void |
publish(ServiceContext serviceContext,
PublishRequest request,
PublishResponse response) |
void |
removeListener(SubscriptionManagerListener listener)
Remove a SubscriptionManagerListener.
|
protected void |
removeSubscription(ServiceContext serviceContext,
Subscription subscription,
boolean removeFromQueue) |
protected void |
removeTriggeringLink(SubscriptionBase s,
MonitoredItemBase triggeringItem,
UnsignedInteger linkToRemove) |
protected void |
republish(ServiceContext serviceContext,
RepublishRequest request,
RepublishResponse response) |
void |
setImmediatePublishing(boolean immediatePublishEnabled)
Enable immediate publishing.
|
void |
setMaxMonitoredItemsPerSubscription(int maxMonitoredItemsPerSubscription) |
void |
setMaxNotificationsPerPublish(int maxNotificationsPerPublish)
Define the limit for MaxNotificationsPerPublish that the clients may define for each
subscription.
|
void |
setMaxPublishingInterval(double maxPublishingInterval)
Define the maximum value for PublishingInterval of any subscription.
|
void |
setMaxPublishRequestCount(int maxPublishRequestCount)
Define the maximum number of PublishRequests to accept from the client at a time.
|
void |
setMaxRetransmissionQueueSize(int maxRetransmissionQueueSize)
Define the maximum number of notification messages to keep in the retransmit queue, which is
used to enable Republish calls from the client.
|
void |
setMaxSamplingInterval(double maxSamplingInterval)
Define the maximum value for SamplingInterval of any MonitoredItem.
|
void |
setMaxSubscriptionCount(int maxSubscriptionCount)
Define the maximum number of Subscriptions to enable per session.
|
void |
setMinPublishingInterval(double minPublishingInterval)
Define the minimum value for PublishingInterval of any subscription.
|
void |
setMinSamplingInterval(double minSamplingInterval)
Define the minimum value for SamplingInterval of any MonitoredItem.
|
protected void |
setMonitoringMode(ServiceContext serviceContext,
Subscription subscription,
UnsignedInteger monitoredItemId,
MonitoringMode mode) |
void |
setNextSubscriptionId(UnsignedInteger subscriptionId)
Set the next SubscriptionId to be used when Clients make Subscriptions.
|
protected void |
setPublishingMode(ServiceContext serviceContext,
UnsignedInteger subscriptionId,
Boolean publishingEnabled) |
void |
setTrackModelChanges(boolean trackModelChanges)
If set to true (by default false), MonitoredItems will work even if an UaNode is deleted and
another UaNode then later added with the same NodeId.
|
protected void |
setTriggering(ServiceContext serviceContext,
SetTriggeringRequest request,
SetTriggeringResponse response) |
protected void |
start()
Starts the manager.
|
protected Subscription |
transferSubscription(ServiceContext serviceContext,
UnsignedInteger subscriptionId,
boolean sendInitialValues)
Handle TransferSubscriptions call.
|
protected final List<SubscriptionManagerListener> listeners
protected final NodeManagerTable nodeManagerTable
protected final SessionManager sessionManager
public SubscriptionManager(SessionManager sessionManager, NodeManagerTable nodeManagerTable)
sessionManager - nodeManagerTable - public void addListener(SubscriptionManagerListener listener)
listener - the listener to add. Must not be nullpublic int getMaxMonitoredItemsPerSubscription()
setMaxMonitoredItemsPerSubscription(int)public int getMaxNotificationsPerPublish()
If this value is defined, the client requested values are modified down to this value, if they would exceed it.
Default: 50000
setMaxNotificationsPerPublish(int)public double getMaxPublishingInterval()
setMaxPublishingInterval(double)public int getMaxPublishRequestCount()
public int getMaxRetransmissionQueueSize()
public double getMaxSamplingInterval()
setMaxSamplingInterval(double)public int getMaxSubscriptionCount()
public double getMinPublishingInterval()
setMinPublishingInterval(double)public double getMinSamplingInterval()
setMinSamplingInterval(double)public UnsignedInteger getNextSubscriptionId()
UaServer.shutdown(int, String) and persisted (outside SDK's scope) and set again via
setNextSubscriptionId(UnsignedInteger) after the application has been restarted to
have a continuous range of SubscriptionIds after a restart.
The default value is Instant.getEpochSecond() from Java Epoch converted to
UnsignedInteger, wrapping back to 1 on UnsignedInteger range overflow.
public NodeManagerTable getNodeManagerTable()
public SessionManager getSessionManager()
public Subscription getSubscription(UnsignedInteger subscriptionId) throws ServiceException
subscriptionId - the IDStatusException - if no subscription is foundServiceExceptionpublic int getSubscriptionCount()
public Collection<Subscription> getSubscriptions()
Subscription(s) in the server. The returned collection is a snapshot
and unmodifiable, i.e. it doesn't contain any newly added Subscriptions after the call is made.
If you wish to observe additions/removals, use
addListener(SubscriptionManagerListener) first, and then call this to get the existing
subscriptions.public boolean hasListener(SubscriptionManagerListener listener)
listener - the listener to checklistener - public boolean isImmediatePublishing()
When enabled, changes in monitored items result into immediate publish notification, if the previous notification was sent longer than PublishInterval ago.
setImmediatePublishing(boolean)public boolean isRunning()
public boolean isTrackModelChanges()
public void removeListener(SubscriptionManagerListener listener)
listener - public void setImmediatePublishing(boolean immediatePublishEnabled)
When enabled, changes in monitored items result into immediate publish notification, if the previous notification was sent longer than PublishInterval ago.
If this setting is enabled, the server will try to dispatch the first notifications as soon as possible. On the other hand, it may be useful to keep this disabled, if your server is generating bursts of value changes every now and then, since the ImmedieatPublish will result into the burst to be broken to two separate notifications that are sent one PublishingInterval apart.
If the ImmediatePublish is disabled, the subscriptions are checked with a fixed PublishingInterval cycle.
Default: false
public void setMaxMonitoredItemsPerSubscription(int maxMonitoredItemsPerSubscription)
getMaxMonitoredItemsPerSubscription()public void setMaxNotificationsPerPublish(int maxNotificationsPerPublish)
Default: 50000
maxNotificationsPerPublish - getMaxNotificationsPerPublish()public void setMaxPublishingInterval(double maxPublishingInterval)
Default: 3600000
maxPublishingInterval - the maxPublishingInterval to set (in milliseconds)public void setMaxPublishRequestCount(int maxPublishRequestCount)
The value defines the maximum per client session.
maxPublishRequestCount - the new limit. Default is 100. Use 0 to set the default value.public void setMaxRetransmissionQueueSize(int maxRetransmissionQueueSize)
maxRetransmissionQueueSize - the new size (default is 10)public void setMaxSamplingInterval(double maxSamplingInterval)
Default: 3600000
maxSamplingInterval - the maxSamplingInterval to set (in milliseconds)public void setMaxSubscriptionCount(int maxSubscriptionCount)
maxSubscriptionCount - the maxSubscriptionCount to set. Default is INTEGER.MAX_VALUEpublic void setMinPublishingInterval(double minPublishingInterval)
Default: 100
minPublishingInterval - the minPublishingInterval to set (in milliseconds). The value must
be greater than 0.public void setMinSamplingInterval(double minSamplingInterval)
Default: 1
minSamplingInterval - the minSamplingInterval to set. (in milliseconds)public void setNextSubscriptionId(UnsignedInteger subscriptionId)
UnsignedInteger.MAX_VALUE). Note that this should not be called while the server is
running. Please see getNextSubscriptionId().subscriptionId - the subscriptionId for the next subscription, this is incremented for
each subscription. If null or 0 is given, 1 is used instead.public void setTrackModelChanges(boolean trackModelChanges)
StatusCodes.Bad_NodeIdUnknown sent when a
node is removed.protected void acknowledge(ServiceContext serviceContext, PublishRequest request, PublishResponse response)
protected void acknowledgeSubscriptions(ServiceContext serviceContext, SubscriptionAcknowledgement[] acks, StatusCode[] results, DiagnosticInfo[] diagnostics)
protected SubscriptionBase addSubscription(ServiceContext serviceContext, CreateSubscriptionRequest request) throws ServiceException
serviceContext - request - ServiceExceptionprotected void addTriggeringLink(Subscription s, MonitoredItemBase triggeringItem, UnsignedInteger linkToAdd) throws StatusException
s - triggeringItem - unsignedInteger - StatusExceptionprotected NumericRange checkIndexRangeForMonitoredItem(String indexRange, UnsignedInteger attributeId) throws ServiceException
indexRange - attributeId - ServiceResultExceptionServiceExceptionprotected void checkSession(ServiceContext serviceContext, Subscription subscription) throws ServiceException
serviceContext - subscription - ServiceExceptionprotected void close()
protected MonitoredDataItem createMonitoredDataItem(ServiceContext serviceContext, Subscription subscription, MonitoredItemCreateRequest itemToCreate, TimestampsToReturn timestampsToReturn, MonitoringFilter filter) throws ServiceException, StatusException
serviceContext - subscription - itemToCreate - timestampsToReturn - filter - StatusExceptionServiceExceptionprotected MonitoredItem createMonitoredEventItem(ServiceContext serviceContext, Subscription subscription, MonitoredItemCreateRequest itemToCreate, EventFilter eventFilter) throws StatusException
serviceContext - subscription - itemToCreate - eventFilter - StatusExceptionprotected MonitoredItem createMonitoredItem(ServiceContext serviceContext, Subscription subscription, TimestampsToReturn timestampsToReturn, MonitoredItemCreateRequest itemToCreate) throws StatusException, ServiceException
serviceContext - subscription - timestampsToReturn - itemToCreate - StatusExceptionServiceExceptionprotected Subscription createSubscription(SubscriptionManager subscriptionManager, UnsignedInteger subscriptionId, Boolean publishingEnabled, double revisedPublishingInterval, UnsignedInteger revisedLifetimeCount, UnsignedInteger revisedMaxKeepAliveCount, UnsignedInteger maxNotificationsPerPublish, UnsignedByte priority)
Subscription.protected MonitoredItemBase deleteMonitoredItem(ServiceContext serviceContext, Subscription subscription, UnsignedInteger itemId) throws StatusException
serviceContext - subscription - itemId - StatusExceptionprotected Subscription getNextSubscriptionToPublish(ServiceContext serviceContext, long timeoutHint) throws ServiceException
serviceContext - timeoutHint - ServiceExceptionprotected BlockingQueue<SubscriptionBase> getPublishQueue(Session session)
session - protected MonitoredItem modifyMonitoredItem(ServiceContext serviceContext, Subscription subscription, MonitoredItemModifyRequest request, TimestampsToReturn timestampsToReturn, MonitoringParameters params) throws StatusException
serviceContext - subscription - request - timestampsToReturn - params - StatusExceptionprotected SubscriptionBase modifySubscription(ServiceContext serviceContext, ModifySubscriptionRequest request) throws ServiceException
serviceContext - request - ServiceExceptionStatusExceptionprotected UnsignedInteger nextSubscriptionId()
protected void publish(ServiceContext serviceContext, PublishRequest request, PublishResponse response) throws ServiceException
ServiceExceptionprotected void removeSubscription(ServiceContext serviceContext, Subscription subscription, boolean removeFromQueue) throws ServiceException
serviceContext - subscription - ServiceExceptionprotected void removeTriggeringLink(SubscriptionBase s, MonitoredItemBase triggeringItem, UnsignedInteger linkToRemove) throws StatusException
s - triggeringItem - unsignedInteger - StatusExceptionprotected void republish(ServiceContext serviceContext, RepublishRequest request, RepublishResponse response) throws ServiceException
ServiceExceptionprotected void setMonitoringMode(ServiceContext serviceContext, Subscription subscription, UnsignedInteger monitoredItemId, MonitoringMode mode) throws ServiceException, StatusException
serviceContext - subscription - monitoredItemId - StatusExceptionServiceExceptionprotected void setPublishingMode(ServiceContext serviceContext, UnsignedInteger subscriptionId, Boolean publishingEnabled) throws ServiceException, StatusException
serviceContext - subscriptionId - publishingEnabled - ServiceExceptionStatusExceptionprotected void setTriggering(ServiceContext serviceContext, SetTriggeringRequest request, SetTriggeringResponse response) throws ServiceException
ServiceExceptionprotected void start()
protected Subscription transferSubscription(ServiceContext serviceContext, UnsignedInteger subscriptionId, boolean sendInitialValues) throws ServiceException
ServiceException - on errorCopyright © 2026. All rights reserved.