Search code examples
azure-cosmosdbazure-cosmosdb-sqlapi

CosmosSDK Java 4.52.0 changeFeedBuilder no longer supports ChangeFeedObserver, how to get the "fetch" ChangeRequest?


In the older SDK version when creating a ChangeFeedProcessor a ChangeFeedObserver implementation should be provided. The ChangeFeedObserver contained the ChangeFeedObserverContext which contains the FeedResponse which contains the requestCharge.

Is there a way to get the requestCharge somehow using the new Publisher based ChangeFeedProcessor initializer?

EDIT: Previous code (SDK 4.37.1):

return new ChangeFeedProcessorBuilderImpl()
    .options(cfOptions)
    .hostName(host)
    .feedContainer(feedInputContainer)
    .leaseContainer(leaseContainer)
    .observerFactory(() -> new CosmosStatisticsChangeFeedObserver(cosmosEventsProcessor, metrics))
    .build();

Where "CosmosStatisticsChangeFeedObserver" is an implementation of ChangeFeedObserver{JsonNode}

New implementation (SDK 4.52.0):

return new ChangeFeedProcessorBuilder()
    .options(cfOptions)
    .hostName(host)
    .feedContainer(feedInputContainer)
    .leaseContainer(leaseContainer)
    .handleLatestVersionChanges(new CosmosChangeFeedChangeHandler(metrics, cosmosEventsProcessor))
    .buildChangeFeedProcessor();

Where "CosmosChangeFeedChangeHandler" is an implementation of "Consumer{List{ChangeFeedProcessorItem}}". (Can't display "<"s)

In the new Consumer based changefeedhandler the "feedResponse" is missing, thus I cannot get the RequestCharge upon receiving feed items. Only "ChangeFeedProcessorItem" is present which doesnt contain RU info.


Solution

  • It seems its not available, created a feature request in Github: https://github.com/Azure/azure-sdk-for-java/issues/37461