Class DataChangeEventProcessor
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
appLifetimeIHostApplicationLifetimeAn 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.
dbConfigIDatabaseOptionsThe database configuration for the CDC processor.
cdcRepositoryCdcRepositoryThe CDC repository for querying change data.
stateStoreConnectionFactoryFunc<IDbConnection>The SQL connection for persisting CDC state.
stateStoreOptionsIOptions<SqlServerCdcStateStoreOptions>The CDC state store options.
serviceProviderIServiceProviderThe service provider for dependency injection.
policyFactoryIDataAccessPolicyFactoryThe factory for creating data access policies.
timeProviderTimeProviderThe time provider used for the stale-position recovery backoff delay, so recovery retries are deterministically testable without wall-clock sleeps.
loggerILogger<DataChangeEventProcessor>The logger for capturing diagnostics and operational logs.
fatalErrorOptionsIOptions<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
cancellationTokenCancellationTokenA token to observe while waiting for the task to complete.