Class SpannerDatabaseTailer

  • All Implemented Interfaces:
    com.google.api.core.ApiService, SpannerDatabaseChangeWatcher

    public class SpannerDatabaseTailer
    extends com.google.api.core.AbstractApiService
    implements SpannerDatabaseChangeWatcher
    Implementation of the SpannerDatabaseChangeWatcher interface that continuously polls a set of tables for changes based on commit timestamp columns in the tables.

    Example usage for watching all tables in a database:

    {@code
     String instance = "my-instance";
     String database = "my-database";
    
     Spanner spanner = SpannerOptions.getDefaultInstance().getService();
     DatabaseId databaseId = DatabaseId.of(SpannerOptions.getDefaultProjectId(), instance, database);
     SpannerDatabaseChangeWatcher watcher =
         SpannerDatabaseTailer.newBuilder(spanner, databaseId).allTables().build();
     watcher.addCallback(
         new RowChangeCallback() {