ChangeFeedProcessor Interface

Definition

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();
public interface ChangeFeedProcessor

Methods

getCurrentState()

Returns a read only list of states each representing 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.

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.

isStarted()

Returns the state of the change feed processor.

start()

Start listening for changes asynchronously.

stop()

Stops listening for changes asynchronously.

Applies to