Table of Contents

Class DataChangeEventProcessor

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

Processes CDC (Change Data Capture) events and delegates handling to registered data change handlers.

public class DataChangeEventProcessor : CdcProcessor, IDataChangeEventProcessor, ISqlServerCdcProcessor, ICdcProcessor<DataChangeEvent>, IAsyncDisposable, IDisposable
Inheritance
DataChangeEventProcessor
Implements
Inherited Members

Constructors

DataChangeEventProcessor(IHostApplicationLifetime, IDatabaseOptions, CdcRepository, Func<IDbConnection>, IOptions<SqlServerCdcStateStoreOptions>?, IServiceProvider, IDataAccessPolicyFactory, TimeProvider, ILogger<DataChangeEventProcessor>, IOptions<CdcFatalErrorOptions<DataChangeEvent>>?)

Initializes a new instance of the DataChangeEventProcessor class.

public DataChangeEventProcessor(IHostApplicationLifetime appLifetime, IDatabaseOptions dbConfig, CdcRepository cdcRepository, Func<IDbConnection> stateStoreConnectionFactory, IOptions<SqlServerCdcStateStoreOptions>? stateStoreOptions, IServiceProvider serviceProvider, IDataAccessPolicyFactory policyFactory, TimeProvider timeProvider, ILogger<DataChangeEventProcessor> logger, IOptions<CdcFatalErrorOptions<DataChangeEvent>>? fatalErrorOptions = null)

Parameters

appLifetime IHostApplicationLifetime

An instance of IHostApplicationLifetime that allows the application to perform actions during the application's lifecycle events, such as startup, shutdown, or when the application is stopping. This parameter is used to gracefully manage tasks that need to respond to application lifecycle events.

dbConfig IDatabaseOptions

The database configuration for the CDC processor.

cdcRepository CdcRepository

The CDC repository for querying change data.

stateStoreConnectionFactory Func<IDbConnection>

The SQL connection for persisting CDC state.

stateStoreOptions IOptions<SqlServerCdcStateStoreOptions>

The CDC state store options.

serviceProvider IServiceProvider

The service provider for dependency injection.

policyFactory IDataAccessPolicyFactory

The factory for creating data access policies.

timeProvider TimeProvider

The time provider used for the stale-position recovery backoff delay, so recovery retries are deterministically testable without wall-clock sleeps.

logger ILogger<DataChangeEventProcessor>

The logger for capturing diagnostics and operational logs.

fatalErrorOptions IOptions<CdcFatalErrorOptions<DataChangeEvent>>

Options containing an optional delegate that is invoked if a fatal error occurs during event processing. This allows the host application to react to unrecoverable conditions (e.g., log, shut down, alert).

Methods

ProcessCdcChangesAsync(CancellationToken)

Processes CDC changes by retrieving and handling data change events.

public Task<int> ProcessCdcChangesAsync(CancellationToken cancellationToken)

Parameters

cancellationToken CancellationToken

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

Returns

Task<int>

The total number of events processed.