Class MssqlCdcSource

java.lang.Object
org.gridgain.internal.cdc.source.mssql.MssqlCdcSource
All Implemented Interfaces:
AutoCloseable, org.gridgain.internal.cdc.api.source.CdcSource

public class MssqlCdcSource extends Object implements org.gridgain.internal.cdc.api.source.CdcSource
CdcSource that reads change events from Microsoft SQL Server's native Change Data Capture.

For each replicated table a TablePoller on its own thread polls the table's capture instance (cdc.fn_cdc_get_all_changes_<instance>) over advancing LSN windows, maps each change row to a TableRowEvent, and pushes each window in bounded chunks, every chunk a batch stamped with its own resume watermark. In CdcReplicationMode.ALL mode an initial snapshot of existing rows (emitted as TableRowEventType.CREATED) precedes incremental polling. A lost connection is re-established with backoff (see the reconnect* parameters in MssqlSourceParameters); a saved position that CDC retention has discarded fails the table's replication with a message naming the recovery.

The capture instance read for a table is SQL Server's default <schema>_<table> unless the source parameter captureInstance.<schema>.<table> names another one. The watermark records the instance it was read from, so that a replication stopped on one instance and started on another (the two-instance hand-over SQL Server uses for a schema change) continues from its saved position, or refuses to when that position lies below the new instance's start.

Captured columns with unmapped types (for example sql_variant or xml) fail at start rather than passing raw driver objects downstream; see MssqlTypeMapping.

Limitations: the ALL-mode snapshot is not transactionally consistent with the start LSN for concurrently-modified rows.

  • Constructor Summary

    Constructors
    Constructor
    Description
    MssqlCdcSource(org.gridgain.internal.cdc.api.source.SourceDefinition source)
    Constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
     
    @Nullable List<org.gridgain.internal.cdc.api.source.SourceColumn>
    describeTable(org.gridgain.internal.cdc.api.source.SourceTableDefinition table)
     
    void
    start(org.gridgain.internal.cdc.api.source.SourceTableDefinition table, byte @Nullable [] lastWatermark, org.gridgain.internal.cdc.api.replication.CdcReplicationMode mode, Flow.Subscriber<org.gridgain.internal.cdc.api.source.WatermarkedBatch> subscriber)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • MssqlCdcSource

      public MssqlCdcSource(org.gridgain.internal.cdc.api.source.SourceDefinition source)
      Constructor.
      Parameters:
      source - Source definition whose parameters describe the SQL Server connection.
  • Method Details

    • describeTable

      @Nullable public @Nullable List<org.gridgain.internal.cdc.api.source.SourceColumn> describeTable(org.gridgain.internal.cdc.api.source.SourceTableDefinition table)
      Specified by:
      describeTable in interface org.gridgain.internal.cdc.api.source.CdcSource
    • start

      public void start(org.gridgain.internal.cdc.api.source.SourceTableDefinition table, byte @Nullable [] lastWatermark, org.gridgain.internal.cdc.api.replication.CdcReplicationMode mode, Flow.Subscriber<org.gridgain.internal.cdc.api.source.WatermarkedBatch> subscriber)
      Specified by:
      start in interface org.gridgain.internal.cdc.api.source.CdcSource
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable