Skip to content

Add durable subscription + transfer WinForms sample - #873

Merged
romanett merged 5 commits into
masterfrom
copilot/implement-durable-transfer-subscriptions-sample
Sep 9, 2026
Merged

romanett merged 5 commits into
masterfrom
copilot/implement-durable-transfer-subscriptions-sample

Conversation

Copilot AI commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

Proposed changes

No sample exercised durable subscriptions or TransferSubscriptions, though docs/DurableSubscription.md and docs/TransferSubscription.md describe four client use cases and the server-side support required. This adds a server + client WinForms sample pair under Workshop/DurableSubscription/ covering both documents, built on the V2 Opc.Ua.Client.Subscriptions engine used by the other client samples.

  • Server — reuses ReferenceServer with DurableSubscriptionsEnabled on, keeping subscriptions and their queued notifications alive while the client is gone. Registered in the solution, SampleCatalog.cs, and ConfigurationFileTests (opc.tcp 62581 / opc.https 62580).
  • Client — creates a durable subscription on the server's CurrentTime; Save & Restart persists it, restarts the process, transfers it back, and flags values queued during the downtime as recovered (classified by SourceTimestamp against the transfer instant).
  • V2 engine, not classic API — the client model drives the four use cases through:
    • managed session via SampleSessionFactory.ConnectAsync (required for the subscription manager)
    • SampleSession.AddSubscription + SubscriptionCallbacks
    • ISubscription.SetAsDurableAsync(TimeSpan)
    • ISubscriptionManager.SaveAsync / LoadAsync(..., transferSubscriptions: true) — snapshot to disk and transfer-back, which drives GetMonitoredItems / TransferSubscriptions internally
  • README — describes the V2 API surface rather than the classic Session/Subscription calls.

The model's public surface is unchanged, so MainForm was untouched by the V2 migration.

Related Issues

Types of changes

What types of changes does your code introduce?
Put an x in the boxes that apply. You can also fill these out after creating the PR.

  • Bugfix (non-breaking change which fixes an issue)
  • Enhancement (non-breaking change which adds functionality)
  • Test enhancement (non-breaking change to increase test coverage)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected, requires version increase of Nuget packages)
  • Documentation Update (if none of the other choices apply)

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.

  • I have read the CONTRIBUTING doc.
  • I have signed the CLA.
  • I ran tests locally with my changes, all passed.
  • I fixed all failing tests in the CI pipelines.
  • I fixed all introduced issues with CodeQL and LGTM.
  • I have added tests that prove my fix is effective or that my feature works and increased code coverage.
  • I have added necessary documentation (if appropriate).
  • Any dependent changes have been merged and published in downstream modules.

Further comments

The client uses the V2 subscription engine for consistency with the other samples; durable/transfer/save-load are all first-class on that engine (SetAsDurableAsync takes a TimeSpan, server may revise the lifetime down to whole hours). The self-contained connect/persist/restart flow is kept rather than the SampleClientModel attach/detach pattern, since the demo intentionally kills and restarts its own process.

Copilot AI and others added 4 commits September 6, 2026 18:43
Co-authored-by: romanett <7413710+romanett@users.noreply.github.com>
Co-authored-by: romanett <7413710+romanett@users.noreply.github.com>
Co-authored-by: romanett <7413710+romanett@users.noreply.github.com>
… engine

Co-authored-by: romanett <7413710+romanett@users.noreply.github.com>
@romanett

romanett commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

@copilot fix the failing tests

Co-authored-by: romanett <7413710+romanett@users.noreply.github.com>

Copilot AI commented Sep 6, 2026

Copy link
Copy Markdown
Contributor Author

@copilot fix the failing tests

Fixed in 3b8c18a. Adding the sample to SampleCatalog made two coverage tests in the "Test Samples" job fail:

  • SampleServerTests.AllSamplesAreCovered — the server had no factory. Registered DurableSubscription in SampleServerFactories (+ project reference in Samples.Servers.Hosting.csproj), so the tier-1 smoke test now starts it (it's the reference server plus durable config, same startup path as the already-covered Reference server).
  • SampleClientTests.UncoveredClientSamplesAreDeclared — the client had no factory. Since this client hosts no shared connect control and, by design, persists its subscription and restarts its own process, it can't be driven by the shared tier-2 loop, so it's declared as a known gap alongside Aggregation/Gds/Sample.

Tier-0 config tests pass (247/247) and the hosting + client test projects build.

@romanett
romanett merged commit ca11fe6 into master Sep 9, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants