Interface ChangeFeedProcessor


public interface ChangeFeedProcessor
Simple host for distributing change feed events across observers, simplifying the process of reading the change feeds and distributing the processing events across multiple consumers effectively.

There are four main components of implementing the change feed processor:

  • The monitored container: the monitored container has the data from which the change feed is generated. Any inserts and updates to the monitored container are reflected in the change feed of the container.
  • The lease container: the lease container acts as a state storage and coordinates processing the change feed across multiple workers. The lease container can be stored in the same account as the monitored container or in a separate account.
  • The host: a host is an application instance that uses the change feed processor to listen for changes. Multiple instances with the same lease configuration can run in parallel, but each instance should have a different instance name.
  • The delegate: the delegate is the code that defines what you, the developer, want to do with each batch of changes that the change feed processor reads.
 ChangeFeedProcessor changeFeedProcessor = new ChangeFeedProcessorBuilder()
     .hostName(hostName)
     .feedContainer(feedContainer)
     .leaseContainer(leaseContainer)
     .handleChanges(docs -> {
         for (JsonNode item : docs) {
             // Implementation for handling and processing of each JsonNode item goes here
         }
     })
     .buildChangeFeedProcessor();
 
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns a read only list of list of objects, each one represents one scoped worker item.
    Returns the current owner (host) and an approximation of the difference between the last processed item (defined by the state of the feed container) and the latest change in the container for each partition (lease item).
    boolean
    Returns the state of the change feed processor.
    Start listening for changes asynchronously.
    Stops listening for changes asynchronously.
  • Method Details

    • start

      Mono<Void> start()
      Start listening for changes asynchronously.
      Returns:
      a representation of the deferred computation of this call.
    • stop

      Mono<Void> stop()
      Stops listening for changes asynchronously.
      Returns:
      a representation of the deferred computation of this call.
    • isStarted

      boolean isStarted()
      Returns the state of the change feed processor.
      Returns:
      true if the change feed processor is currently active and running.
    • getEstimatedLag

      Mono<Map<String,Integer>> getEstimatedLag()
      Returns the current owner (host) and an approximation of the difference between the last processed item (defined by the state of the feed container) and the latest change in the container for each partition (lease item).

      An empty map will be returned if the processor was not started or no lease items matching the current ChangeFeedProcessor instance's lease prefix could be found.

      Returns:
      a map representing the current owner and lease token, the current LSN and latest LSN, and the estimated lag, asynchronously.
    • getCurrentState

      Mono<List<ChangeFeedProcessorState>> getCurrentState()
      Returns a read only list of list of objects, each one represents one scoped worker item.

      An empty list will be returned if the processor was not started or no lease items matching the current ChangeFeedProcessor instance's lease prefix could be found.

      Returns:
      a Mono containing a read only list of objects, each one representing one scoped worker item.