CDC Java Client API
Consuming CDC records requires the use of a library that translates the data stream into workable data structures. The CDC Java Client API is a set of interfaces and classes that allow you to process CDC records from the server using an easily consumable API.
Prerequisites for Java Client Configuration
• Java 11 or later
• Ingres JDBC Driver 4.4.4 or later
• Ingres CDC API
Setting up the CDC Java Client
The CDC Java Client API and the associated Javadocs are available for download from Maven Central using the link below:
You can download the jar file directly or use a build tool like Maven or Gradle. The coordinates to download are:
GroupID : com.ingres.cdc
ArtifactID: ingres-cdc-client
Version: 1.0.0+
Configuring a new CDC Session
To establish a CDC session, you must create a Builder object that describes the session you intend to establish. You can specify a java.sql.DataSource in the builder or pass in a URL later when you build the session. Setting a timeout is important to ensure the thread does not block indefinitely. CDC Log Streams are backed by JDBC connections which use blocking network calls.
CDCLogStream.Builder builder = CDCLogStream.builder()
.datasource(ingresDataSource) //Datasource to connect with
.timeout(5) //Timeout in seconds to wait for new records
.name("CDC Transaction Watcher") //Name of the log stream session
.publication(pub); //Add one or more publications to watch
Configuring Tables to Stream Data
To stream data from one or more tables with CDC, you must define the Publication objects that specify the table(s) to be monitored for data changes.The required parameters must be defined before you build the CDC connection as they cannot be modified after starting the CDC session. You can monitor multiple tables within a single CDC session or you can monitor each table in a separate CDC session.
Note: You cannot change parameters after starting the CDC session.
CDCPublication pub = new CDCPublication()
.name("My Table Publication") //Publication name
.owner("table owner") //Owner of the table
.table("table name") //Table name
.columns("*") //Optional columns to watch, use '*' for all columns, or list
of columns separated by comma
.attributes(CDCPublication.FULL_BEFORE_IMAGE)
.filter("txn_amount > 1000"); //Optional filter
Starting a CDC Session
Populate the Builder object with the desired options and tables to monitor, then call the build() method to start the session. The CDCLogStream object implements AutoClosable and java.util.function.Supplier interfaces.
try(CDCLogStream logStream = builder.build()) {
//Blocking call to get the next record
LogRecord record = logStream.get();
//Use a stream to print all records as they arrive
Stream.generate(() -> logStream.get())
.forEach(System.out::println);
Last modified date: 01/27/2026