Class SpannerTableTailer

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

    public class SpannerTableTailer
    extends com.google.api.core.AbstractApiService
    implements SpannerTableChangeWatcher
    Implementation of the SpannerTableChangeWatcher interface that continuously polls a table for changes based on a commit timestamp column in the table.

    Usage:

    {@code
     String instance = "my-instance";
     String database = "my-database";
     String table = "MY_TABLE";
    
     Spanner spanner = SpannerOptions.getDefaultInstance().getService();
     TableId tableId =
         TableId.of(DatabaseId.of(SpannerOptions.getDefaultProjectId(), instance, database), table);
     SpannerTableChangeWatcher watcher = SpannerTableTailer.newBuilder(spanner, tableId).build();
     watcher.addCallback(
         new RowChangeCallback() {
    • Method Detail

      • getLastPollStatement

        public com.google.cloud.spanner.Statement getLastPollStatement()
        Returns the last poll statement of this tailer. This can be used to monitor the polling activity by querying the SPANNER_SYS views for query statistics for this statement.
      • isLastPollReturnedChanges

        public boolean isLastPollReturnedChanges()
        Returns true if the last poll for changes actually returned changes. This can be used to monitor the polling activity.
      • doStart

        protected void doStart()
        Specified by:
        doStart in class com.google.api.core.AbstractApiService
      • notifyFailed

        protected void notifyFailed​(Throwable cause)
        Overrides:
        notifyFailed in class com.google.api.core.AbstractApiService
      • doStop

        protected void doStop()
        Specified by:
        doStop in class com.google.api.core.AbstractApiService