Interface NoSQLSubscriber

  • All Superinterfaces:
    Subscriber<StreamOperation>

    public interface NoSQLSubscriber
    extends Subscriber<StreamOperation>
    The subscriber interface is to be implemented by the application. The NoSQLSubscriber interface defines additional methods that are described below along with details of NoSQL-specific considerations for the existing methods.

    Implementation of NOSQLSubscriber should follow the Subscriber rules in the Reactive Streams Specification.

    • Method Detail

      • onNext

        void onNext​(StreamOperation t)
        Signals the next NoSQL Operation.

        The sequence of onNext calls represents the stream of changes, both updates and deletions, made to the store. The order of calls to onNext for a given key represents the exact order of the operations on that key performed on the store. There are no guarantees about the order of operations across different keys in the stream.

        If a shard is down, events associated with rows stored on that shard could be arbitrarily delayed until the shard comes back up again and the NoSQL Publisher can establish a shard stream to it.

        Specified by:
        onNext in interface Subscriber<StreamOperation>
      • onError

        void onError​(java.lang.Throwable t)
        Signals an unrecoverable error in subscription.

        There are many potential sources of error that the publisher may signal via this method. One of them is worth special mention: the publisher may invoke this method if it finds that it cannot resume the stream from NoSQLSubscriptionConfig.getInitialPosition() because the relevant logs are no longer available at one of the shards.

        Specified by:
        onError in interface Subscriber<StreamOperation>
      • onComplete

        void onComplete()
        Signals the completion of a subscription

        Note streaming from kvstore table is unbounded by nature since unbounded updates can be applied to a table. Thus onComplete() will never be called in Stream API. User of Stream API shall implement this method as no-op and any no-op implementation will be ignored.

        Specified by:
        onComplete in interface Subscriber<StreamOperation>
      • getSubscriptionConfig

        NoSQLSubscriptionConfig getSubscriptionConfig()
        Invoked by the NoSQL publisher when creating a Subscription. The implementation of this method should return a configuration that identifies the desired position for starting streaming, the tables whose data should be streamed, and other configuration information.

        An ill configuration or null return will cancel the subscription and the publisher will release all resources allocated for that subscription.

        Returns:
        the configuration for creating the subscription
      • onWarn

        void onWarn​(java.lang.Throwable t)
        Signals a warning during subscription.

        A call to this method warns the user of a potential issue that does not yet represent a disruption in service, for example, a warning that a shard was not available for an extended period of time. Note that onWarn, unlike onError, does not terminate the flow of signals. It's used to warn the subscriber that the publisher's functioning is impaired, but not as yet fatally and some exception-specific action could be taken to restore the health of the Publisher.

      • onCheckpointComplete

        void onCheckpointComplete​(StreamPosition streamPosition,
                                  java.lang.Throwable failureCause)
        Signals when a previously requested checkpoint is completed. If checkpoint fails for any reason, the subscription will skip this checkpoint for certain shards and continue streaming. The subscription will try the next checkpoint when it comes.

        Note that the stream position checkpoint may not be the one originally supplied if NoSQLSubscription.doCheckpoint(StreamPosition, boolean) is called to do checkpoint with exact is set to false.

        Parameters:
        streamPosition - the stream position in checkpoint
        failureCause - null if checkpoint succeeds, otherwise the cause of checkpoint failure.