[ 
https://issues.apache.org/jira/browse/CAMEL-24382?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Andrea Cosentino updated CAMEL-24382:
-------------------------------------
    Fix Version/s: 4.22.1

> camel-azure-cosmosdb: change-feed consumer checkpoints the lease before the 
> exchange is processed, losing events on failure
> ---------------------------------------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-24382
>                 URL: https://issues.apache.org/jira/browse/CAMEL-24382
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-azure
>            Reporter: Andrea Cosentino
>            Assignee: Andrea Cosentino
>            Priority: Major
>             Fix For: 4.22.1, 4.23.0
>
>
> h3. Problem
> {{CosmosDbConsumer.onEventListener}} dispatches the exchange fire-and-forget 
> and returns immediately:
> {code:java}
> exchange.getExchangeExtension().addOnCompletion(onCompletion);
> getAsyncProcessor().process(exchange, EmptyAsyncCallback.get());
> {code}
> The change feed is driven by the Azure SDK {{ChangeFeedProcessor}} built with 
> a synchronous {{handleChanges(Consumer<List<...>>)}} handler (see 
> {{CosmosDbContainerOperations.captureEventsWithChangeFeed}}). The SDK 
> checkpoints the lease once that handler returns - which happens as soon as 
> {{onEventListener}} has *queued* the exchange, i.e. *before* the route has 
> processed it.
> {{ConsumerOnCompletion}} only implements {{onFailure}} (it logs). So when the 
> route fails, the lease has already advanced and the batch is never 
> redelivered: the change feed is effectively at-most-once and silently loses 
> data on any downstream failure or on shutdown mid-batch.
> h3. Fix
> Defer the checkpoint until the exchange completes - process synchronously 
> inside the handler (block until the AsyncCallback fires) or adopt the 
> {{Mono}}-returning change-feed handler so the SDK only checkpoints after 
> successful processing. Confirm SDK checkpoint timing against the decompiled 
> azure-cosmos jar (as for CAMEL-24158); throughput/back-pressure and shutdown 
> behaviour need care.
> Found reviewing the camel-azure modules not covered by the July 2026 review 
> (CAMEL-24158/24159). Affects main (4.22.0-SNAPSHOT).



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to