ข้ามไปยังเนื้อหา

Cephalon.Data.SqlServer

เนื้อหานี้ยังไม่ได้แปลเป็นภาษาไทย แสดงเป็นภาษาอังกฤษแทน

Maturity: M2 · Ownership: provider-managed · Family: data-and-cdc · See audit, matrix.

Cephalon.Data.SqlServer is the SQL Server provider-native CDC companion pack for Cephalon. It proves that the shared Cephalon.Data CDC execution/runtime catalog family also fits a relational provider with durable LSN checkpoints, change-table polling, and module-preserving ownership truth without any SQL Server-specific registry in Cephalon.Engine.

  • contributes configured provider-native SQL Server CDC captures through SqlServerCdcCaptureOptions and keeps those descriptors on the shared /engine/cdc-captures* catalog with provider = "sqlserver" and mode = "change-table"
  • publishes capability metadata data.sqlserver, data.relational-store, and data.cdc.sqlserver introspectable at runtime through the manifest
  • publishes the provider-native CDC execution graph sqlserver-cdc-capture-flow, hosted execution sqlserver-cdc-capture-pump, and execution runtime sqlserver-cdc-capture-pump when SQL Server CDC captures are configured
  • runs a provider-native hosted service that polls configured SQL Server CDC change tables, stages outbox publications, persists SQL Server checkpoint tokens only after outbox stage success, and reports runtime posture through the shared ICdcCaptureRuntimeReporter surface
  • stores durable SQL Server CDC checkpoints in a Cephalon-managed checkpoint table, defaulting to dbo.cephalon_cdc_checkpoints
  • preserves authored capture ownership through CdcCaptureDescriptor.SourceModuleId while surfacing metadata.contributorModuleId = "sqlserver-data" when the provider pack contributes the descriptor on behalf of another module
  • Configuration/SqlServerDataOptions.cs
  • Configuration/SqlServerCdcCaptureOptions.cs
  • Modules/SqlServerDataModule.cs
  • Registration/SqlServerDataEngineBuilderExtensions.cs
  • Services/SqlServerCdcCaptureHostedService.cs
  • Services/SqlServerCdcCheckpointToken.cs
  • Services/SqlServerCdcExecutionRuntimeContributor.cs
  • Services/SqlServerCdcTransport.cs
  • Services/SqlServerDataRuntimeIds.cs

This pack sits on top of Cephalon.Data, not in place of it. Cephalon.Data still owns the runtime-neutral CDC descriptor catalog, capture-side execution binding, shared runtime-state catalog, additive execution-runtime catalog, and optional external runtime reporting seam. Cephalon.Data.SqlServer adds the SQL Server-specific change-table reader, durable checkpoint store, and provider-native hosted execution loop needed to project truthful SQL Server CDC behavior into those shared surfaces.

That keeps the engine honest. The shared data-cdc-capture-pump still exists as the generic in-process runtime, but it simply ignores captures whose effective owner resolves to sqlserver-cdc-capture-pump. The SQL Server pack becomes the second concrete provider-native CDC runner after MongoDB, and the first relational runner on the same ownership/topology model.

The slice stays intentionally scoped. Cephalon.Data.SqlServer does not claim general-purpose IReadStore or IWriteStore dispatch, DbContext integration, SQL Server outbox storage, or SQL Server inbox storage. If a host wants relational read/write persistence today, Cephalon.Data.EntityFramework remains the honest baseline. Cephalon.Data.SqlServer only claims provider-native CDC capture plus durable checkpoint truth.

engine.AddData(options =>
{
options.EnableCdcExecution = true;
});
engine.AddSqlServerData(
connectionString: "Server=localhost;Database=app;Integrated Security=true;TrustServerCertificate=true",
databaseName: "app",
configure: options =>
{
options.CdcCaptures.Add(new SqlServerCdcCaptureOptions
{
Id = "orders-cdc",
DisplayName = "Orders CDC",
SourceModuleId = "orders",
CaptureInstance = "dbo_orders",
TableSchema = "dbo",
TableName = "orders",
OutboxId = "tenant-event-outbox",
ChannelId = "orders",
MessageType = "OrdersChanged"
});
});

For configuration-driven hosts, prefer the options overload and bind from Engine:Data:SqlServer:

engine.AddData(options =>
{
options.EnableCdcExecution = true;
});
engine.AddSqlServerData(options =>
{
configuration.GetSection(SqlServerDataOptions.SectionPath).Bind(options);
options.ConnectionStringName ??= "SqlServer";
options.DatabaseName = "app";
});
{
"ConnectionStrings": {
"SqlServer": "Server=localhost;Database=app;Integrated Security=true;TrustServerCertificate=true"
},
"Engine": {
"Data": {
"SqlServer": {
"ConnectionStringName": "SqlServer",
"DatabaseName": "app",
"CheckpointTableSchema": "dbo",
"CheckpointTableName": "cephalon_cdc_checkpoints",
"CdcCaptures": [
{
"Id": "orders-cdc",
"DisplayName": "Orders CDC",
"SourceModuleId": "orders",
"CaptureInstance": "dbo_orders",
"TableSchema": "dbo",
"TableName": "orders",
"OutboxId": "tenant-event-outbox",
"ChannelId": "orders",
"MessageType": "OrdersChanged",
"InitialPosition": "latest-available",
"MaxChangesPerPoll": 128,
"PollingIntervalSeconds": 5
}
]
}
}
}
}

ConnectionStringName and ConnectionString are mutually exclusive. If both are set, the pack fails fast during service resolution. If neither is set, the SQL Server provider cannot start.

Configuration options (Engine:Data:SqlServer)

Section titled “Configuration options (Engine:Data:SqlServer)”
OptionTypeDefaultDescription
ConnectionStringNamestring?nullRoot ConnectionStrings key to resolve for SQL Server
ConnectionStringstring?nullInline SQL Server connection string
DatabaseNamestringrequiredOperator-facing database name for the configured CDC captures
CheckpointTableSchemastring"dbo"Schema that stores Cephalon-managed CDC checkpoints
CheckpointTableNamestring"cephalon_cdc_checkpoints"Table that stores Cephalon-managed CDC checkpoints
CdcCapturesSqlServerCdcCaptureOptions[][]Contribute provider-native SQL Server CDC captures

SQL Server CDC capture options (Engine:Data:SqlServer:CdcCaptures[])

Section titled “SQL Server CDC capture options (Engine:Data:SqlServer:CdcCaptures[])”
OptionTypeDefaultDescription
IdstringrequiredStable CDC capture id
DisplayNamestringIdOperator-facing capture name
DescriptionstringgeneratedHuman-readable capture description
SourceModuleIdstringrequiredModule id that owns the capture surface
SourceIdstring{provider}:{database}/{schema}.{table}Logical upstream source id when it should differ from the watched table path
CaptureInstancestringrequiredSQL Server CDC capture-instance name
TableSchemastring"dbo"Schema name of the tracked table
TableNamestringrequiredTable name of the tracked table
OutboxIdstringrequiredLinked outbox id that receives publications
ChannelIdstringrequiredLogical outbox channel id for emitted publications
MessageTypestringrequiredLogical message type for emitted publications
EventFormatstring"sqlserver-cdc-change-table-event"Operator-facing event format projected on the descriptor
InitialPositionstring"latest-available"Initial position when no durable checkpoint exists yet; supported values are latest-available and earliest-available
MaxChangesPerPollint128Maximum number of captured changes to stage during one polling iteration
PollingIntervalSecondsint5Polling interval in seconds for one provider-native iteration
ResourceIdsstring[]["{database}.{schema}.{table}"]Explicit logical resources observed by the capture
Tagsstring[]["cdc", "sqlserver", "provider-native"]Operator-facing tags on the descriptor
MetadataDictionary<string,string>{}Additional operator-facing metadata merged onto the descriptor

When CdcCaptures are configured:

  • each capture is published through /engine/cdc-captures* with provider = "sqlserver", mode = "change-table", and an executionBinding whose authored and requested runtime id is sqlserver-cdc-capture-pump
  • the execution runtime is published through /engine/cdc-capture-runtimes* and snapshot.CdcCaptureExecutionRuntimes with executionOwnership = host-managed, executionTopology = provider-native, and acknowledgementMode = provider-native
  • the same runtime publishes through /engine/execution-graphs, /engine/hosted-executions, /engine/runtime-story, and snapshot under sqlserver-cdc-capture-flow plus sqlserver-cdc-capture-pump
  • the hosted runner polls one SQL Server CDC change table per configured capture, stages one outbox message per captured row, and only persists the latest SQL checkpoint after the linked outbox accepted the batch
  • each staged outbox message uses deterministic id {cdcCaptureId}:{startLsn}-{sequenceValue}-{operation}, content type application/vnd.cephalon.sqlserver.cdc+json, headers for provider, cdcCaptureId, databaseName, schemaName, tableName, captureInstance, and operation, plus metadata for sourceId, eventFormat, and checkpointToken
  • the runtime-state surface keeps typed freshness, lag, pending-publication posture, checkpoint, change id, last operation type, checkpoint store, and failure-kind metadata on the same /engine/cdc-captures/runtime* catalog instead of inventing a SQL Server-specific monitor
  • if a provider pack contributes a descriptor on behalf of another module, the authored SourceModuleId remains authoritative and metadata.contributorModuleId keeps the contributing pack explicit

Checkpoint table schema (cephalon_cdc_checkpoints)

Section titled “Checkpoint table schema (cephalon_cdc_checkpoints)”

The default table name is {CheckpointTableSchema}.{CheckpointTableName}.

ColumnSQL typeNotes
CdcCaptureIdnvarchar(128)Stable CDC capture id; one checkpoint row per capture
CheckpointStartLsnvarbinary(10)Latest durable __$start_lsn
CheckpointSequenceValuevarbinary(10)Latest durable __$seqval
CheckpointOperationintLatest durable __$operation
CheckpointTokennvarchar(256)Serialized checkpoint token in `startLsn
UpdatedAtUtcdatetimeoffset(7)UTC timestamp of the last durable checkpoint write

When SqlServerDataModule is active, the following capability keys appear in the runtime manifest:

Capability keyWhen registered
data.sqlserverAlways
data.relational-storeAlways
data.cdc.sqlserverCdcCaptures.Count > 0

This pack intentionally still does not claim:

  • IReadStore / IWriteStore dispatch backed directly by SQL Server
  • Entity Framework or DbContext integration
  • SQL Server-backed IOutbox, IInbox, or event-dispatch storage
  • SQL Agent, Debezium, or out-of-process SQL Server CDC execution ownership
  • net-new control plane for CDC monitoring outside the shared /engine/cdc-* surfaces
  • low-code generation or multi-table orchestration beyond one configured capture per SQL Server CDC capture instance

These remain later slices so the current provider claim stays truthful.