The durable subscriptions service enables long lifetimes of subscriptions with big queue sizes and therefore zero-dataloss scenarios. If the connection to the client fails the server continues to sample values. On reconnect the client can use the transfer subscription service to gain access to the missed values.
- If a custom implementation of
INodeManageris used, or the MethodCreateMonitoredItemsis overridden, add the new parametercreateDurable. As long as durable Subscriptions are not enabled in the configuration this parameter can be ignored. - Implement
INodeManager.RestoreMonitoredItems, this method is only called if durable subscriptions are enabled in the server configuration. - If a custom
IMonitoredItemimplementation is used, setIsDurableto false. Implement aDisposemethod.
Typically the following porting steps are necessary:
- Provide an implementation of
IMonitoredItemQueueFactorythat setsSupportsDurableQueuesto true. This factory returns your own implementation ofIMonitoredItemQueuethat persists values to storage and supports large queue sizes. As a reference see DurableMonitoredItemQueueFactory. - Register the
IMonitoredItemQueueFactoryby overriding the StandardServer methodCreateMonitoredItemQueueFactory. - Provide an implementation of
ISubscriptionStorethat persists and restores subscriptions to storage to continue them after a server restart. The subscription store shall also enshure persistent queues are provided to the monitored items after a restore. -
- Register the
ISubscriptionStoreby overriding the StandardServer methodCreateSubscriptionStore.
- Register the
- If a custom implementation of
INodeManageris used, or the MethodCreateMonitoredItemsis overridden, add the new parametercreateDurable. Pass the value of this parameter to the MonitoredItem constructor. If a custom queue length check if performed for durable subscriptions check against the durable queue length from SererConfiguration. - If a custom
IMonitoredItemimplementation is used, implement theIsDurableproperty. Implement aDisposemethod. Add acreateDurableparamter to the constructor. - Make the custom
MonitoredItemuse theIMonitoredItemQueueFactoryfromIServerInternal.MonitoredItemQueueFactoryto get the registerd durable queues instead of using internal queues for events & value changes. - To test custom queues use the unit tests in Server Test Project in the file monitoredItemTests and adapt to use your own queue by providing your
IMonitoredItemQueueFactoryin the constructor.
Extend the ServerConfiguration
- Set
DurableSubscriptionsEnabledto true - Set
MaxDurableNotificationQueueSizeto the desired value - Set
MaxDurableEventQueueSizeto the desired value - Set
MaxDurableSubscriptionLifetimeto the desired value
- Subscriptions are only persistet on a gracefuls shutdown. If the server crashes or needs to be shut down forcefully all
Subscriptions/MonitoredItemsare lost. - Breaking change: The Interfaces for INodeManager & IMonitoredItem were extended to support durable subscriptions.