davsclaus commented on code in PR #27347:
URL: https://github.com/apache/camel/pull/27347#discussion_r4181088656


##########
components/camel-couchbase/src/main/java/org/apache/camel/component/couchbase/CouchbaseConsumer.java:
##########
@@ -277,6 +270,31 @@ private int pollWithView() throws Exception {
         return processBatch(exchanges);
     }
 
+    /**
+     * Removes the document once its exchange has been processed successfully.
+     * <p/>
+     * Removing it while the exchanges are built, before any of them is handed 
to the route, loses the document when its
+     * exchange fails, or when it is never delivered at all because the batch 
is cut short by {@code maxMessagesPerPoll}
+     * or by the consumer stopping. The on-completion runs only for an 
exchange that went through the route and
+     * completed: a failed exchange keeps its document for the next poll, and 
an undelivered one is not touched.
+     */
+    private void removeDocumentOnCompletion(Exchange exchange, String id) {
+        exchange.getExchangeExtension().addOnCompletion(new 
SynchronizationAdapter() {

Review Comment:
   Question: `SynchronizationAdapter` allows handover by default. If the route 
hands the exchange to another thread (e.g. `seda` with 
`waitForTaskToComplete=Never`, or `threads`), the delete runs only when that 
exchange completes, which can be after the next poll has re-read the same 
document, so it may be delivered twice. Is that acceptable (aws2-s3 behaves the 
same), or should `allowHandover()` return `false`?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to