Table of Contents

Interface ICdcRepository

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

Defines the core contract for retrieving Change Data Capture (CDC) data from SQL Server.

public interface ICdcRepository : IAsyncDisposable, IDisposable
Inherited Members

Remarks

This interface contains the 5 essential methods for CDC processing: LSN navigation, position retrieval, change detection, and change fetching. For LSN-to-time mapping and advanced navigation, see ICdcRepositoryLsnMapping.

Methods

ChangesExistAsync(byte[], byte[], IEnumerable<string>, CancellationToken)

Checks if changes exist between two LSN positions for the specified capture instances.

Task<bool> ChangesExistAsync(byte[] fromPosition, byte[] toPosition, IEnumerable<string> captureInstances, CancellationToken cancellationToken)

Parameters

fromPosition byte[]

The starting LSN position.

toPosition byte[]

The ending LSN position.

captureInstances IEnumerable<string>

A collection of capture instance names to query for changes.

cancellationToken CancellationToken

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

Returns

Task<bool>

A task that represents the asynchronous operation, containing a boolean indicating whether changes exist.

FetchChangesAsync(string, int, byte[], byte[], byte[]?, CdcOperationCodes, CancellationToken, string?)

Fetches change rows within an LSN range for the specified capture instance.

Task<IEnumerable<CdcRow>> FetchChangesAsync(string captureInstance, int batchSize, byte[] fromLsn, byte[] toLsn, byte[]? lastSequenceValue, CdcOperationCodes lastOperation, CancellationToken cancellationToken, string? logicalTableName = null)

Parameters

captureInstance string

A capture instance table name to query for changes.

batchSize int

The number of records to retrieve in the batch.

fromLsn byte[]

The starting LSN position (inclusive).

toLsn byte[]

The ending LSN position (inclusive).

lastSequenceValue byte[]

The last processed sequence value, if any. This is used for processing changes with finer granularity.

lastOperation CdcOperationCodes

The CDC operation code filter for the types of changes to retrieve.

cancellationToken CancellationToken

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

logicalTableName string

The logical table name to use in TableName instead of the capture instance. When null, the capture instance name is used (backward-compatible default). This allows handlers to match on the consumer-configured table name (e.g., dbo.Customers) rather than the SQL Server capture instance name (e.g., dbo_Customers).

Returns

Task<IEnumerable<CdcRow>>

An asynchronous stream of CdcRow instances representing the captured changes.

GetMaxPositionAsync(CancellationToken)

Retrieves the maximum LSN currently available in the database.

Task<byte[]> GetMaxPositionAsync(CancellationToken cancellationToken)

Parameters

cancellationToken CancellationToken

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

Returns

Task<byte[]>

A task that represents the asynchronous operation, containing the maximum LSN as a byte array.

GetMinPositionAsync(string, CancellationToken)

Retrieves the minimum LSN for a specific capture instance.

Task<byte[]> GetMinPositionAsync(string captureInstance, CancellationToken cancellationToken)

Parameters

captureInstance string

The capture instance to query.

cancellationToken CancellationToken

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

Returns

Task<byte[]>

A task that represents the asynchronous operation, containing the minimum LSN as a byte array.

GetNextLsnAsync(byte[], CancellationToken)

Retrieves the next Log Sequence Number (LSN) after the specified last processed LSN.

Task<byte[]> GetNextLsnAsync(byte[] lastProcessedLsn, CancellationToken cancellationToken)

Parameters

lastProcessedLsn byte[]

The LSN from which to find the next LSN.

cancellationToken CancellationToken

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

Returns

Task<byte[]>

A task that represents the asynchronous operation, containing the next LSN as a byte array.