Table of Contents

Interface ISqlServerCdcStateStore

Namespace
Excalibur.Cdc.SqlServer
Assembly
Excalibur.Cdc.SqlServer.dll

Defines the contract for managing the state of Change Data Capture (CDC) processing.

public interface ISqlServerCdcStateStore : ICdcStateStore, IAsyncDisposable, IDisposable
Inherited Members

Remarks

Extends the provider-neutral ICdcStateStore so SQL Server CDC state stores are conformable to the generic consumer-checkpoint contract (crash recovery, consumer tracking, progress monitoring) in addition to the SQL Server-specific LSN/sequence-value surface. The generic checkpoint rows share the same table, distinguished by empty database/table discriminators — mirroring the adapter pattern used by the Postgres, MongoDB, CosmosDB, DynamoDB, and Firestore state stores.

Methods

GetLastProcessedPositionAsync(string, string, CancellationToken)

Retrieves the last processed position for a specified database connection and name.

Task<IEnumerable<CdcProcessingState>> GetLastProcessedPositionAsync(string databaseConnectionIdentifier, string databaseName, CancellationToken cancellationToken)

Parameters

databaseConnectionIdentifier string

The unique identifier for the database connection.

databaseName string

The name of the database to retrieve the processing state for.

cancellationToken CancellationToken

A token to observe while waiting for the task to complete.

Returns

Task<IEnumerable<CdcProcessingState>>

A task that represents the asynchronous operation, containing a collection of the last processed CdcProcessingState for each capture instance.

UpdateLastProcessedPositionAsync(string, string, string, byte[], byte[]?, DateTime?, long?, CancellationToken)

Updates the last processed position for a specified database connection and name.

Task<int> UpdateLastProcessedPositionAsync(string databaseConnectionIdentifier, string databaseName, string tableName, byte[] position, byte[]? sequenceValue, DateTime? commitTime, long? fencingToken, CancellationToken cancellationToken)

Parameters

databaseConnectionIdentifier string

The unique identifier for the database connection.

databaseName string

The name of the database to update the processing state for.

tableName string

The name of the table to update the processing state for.

position byte[]

The LSN position to set as the last processed position.

sequenceValue byte[]

The sequence value associated with the last processed position, if any.

commitTime DateTime?

The commit time of the last processed LSN.

fencingToken long?

The current leadership tenure's fencing token, or null when leader-election fencing is not configured. When non-null, the checkpoint write is a non-decreasing compare-and-swap: it is applied only if the stored token is less than or equal to this token (a demoted leader presenting an older token is rejected, leaving the LSN checkpoint unchanged — no regression or skip). The return value is the number of rows written, so 0 with a non-null token signals a superseded leader.

cancellationToken CancellationToken

A token to observe while waiting for the task to complete.

Returns

Task<int>

The number of rows written (0 when a non-null fencing token was superseded).