Package com.azure.cosmos
Class ChangeFeedProcessorBuilder
- java.lang.Object
-
- com.azure.cosmos.ChangeFeedProcessorBuilder
-
public class ChangeFeedProcessorBuilder extends Object
Helper class to build aChangeFeedProcessor
instance.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();
-
-
Constructor Summary
Constructors Constructor Description ChangeFeedProcessorBuilder()
Instantiates a new Cosmos a new ChangeFeedProcessor builder.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ChangeFeedProcessor
buildChangeFeedProcessor()
Builds a new instance of theChangeFeedProcessor
with the specified configuration.ChangeFeedProcessorBuilder
feedContainer(CosmosAsyncContainer feedContainer)
Sets and existingCosmosAsyncContainer
to be used to read from the monitored container.ChangeFeedProcessorBuilder
handleChanges(Consumer<List<JsonNode>> consumer)
Sets a consumer function which will be called to process changes.ChangeFeedProcessorBuilder
hostName(String hostName)
Sets the host name.ChangeFeedProcessorBuilder
leaseContainer(CosmosAsyncContainer leaseContainer)
Sets an existingCosmosAsyncContainer
to be used to read from the leases container.ChangeFeedProcessorBuilder
options(ChangeFeedProcessorOptions changeFeedProcessorOptions)
Sets theChangeFeedProcessorOptions
to be used.
-
-
-
Method Detail
-
hostName
public ChangeFeedProcessorBuilder hostName(String hostName)
Sets the host name.- Parameters:
hostName
- the name to be used for the host. When using multiple hosts, each host must have a unique name.- Returns:
- current Builder.
-
feedContainer
public ChangeFeedProcessorBuilder feedContainer(CosmosAsyncContainer feedContainer)
Sets and existingCosmosAsyncContainer
to be used to read from the monitored container.- Parameters:
feedContainer
- the instance ofCosmosAsyncContainer
to be used.- Returns:
- current Builder.
-
leaseContainer
public ChangeFeedProcessorBuilder leaseContainer(CosmosAsyncContainer leaseContainer)
Sets an existingCosmosAsyncContainer
to be used to read from the leases container.- Parameters:
leaseContainer
- the instance ofCosmosAsyncContainer
to use.- Returns:
- current Builder.
-
handleChanges
public ChangeFeedProcessorBuilder handleChanges(Consumer<List<JsonNode>> consumer)
Sets a consumer function which will be called to process changes..handleChanges(docs -> { for (JsonNode item : docs) { // Implementation for handling and processing of each JsonNode item goes here } })
- Parameters:
consumer
- theConsumer
to call for handling the feeds.- Returns:
- current Builder.
-
options
public ChangeFeedProcessorBuilder options(ChangeFeedProcessorOptions changeFeedProcessorOptions)
Sets theChangeFeedProcessorOptions
to be used. Unless specifically set the default values that will be used are:- maximum items per page or FeedResponse: 100
- lease renew interval: 17 seconds
- lease acquire interval: 13 seconds
- lease expiration interval: 60 seconds
- feed poll delay: 5 seconds
- maximum scale count: unlimited
- Parameters:
changeFeedProcessorOptions
- the change feed processor options to use.- Returns:
- current Builder.
-
buildChangeFeedProcessor
public ChangeFeedProcessor buildChangeFeedProcessor()
Builds a new instance of theChangeFeedProcessor
with the specified configuration.- Returns:
- an instance of
ChangeFeedProcessor
.
-
-