davsclaus opened a new pull request, #30793:
URL: https://github.com/apache/camel/pull/30793

   ## Description
   
   [CAMEL-27536](https://issues.apache.org/jira/browse/CAMEL-27536): a route 
with the pausable EIP (`.pausable(new KafkaConsumerListener(), check)`) kept 
consuming after it was suspended (route controller, JMX, or a 
`ThrottlingExceptionRoutePolicy` that opened its circuit).
   
   `KafkaFetchRecords` called `KafkaConsumerListener.afterConsume` on every 
poll, whatever the state of the task. While the check of the pausable EIP 
holds, the listener calls `consumer.resume(consumer.assignment())`, which undid 
the pause that `updateTaskState()` applied for the suspend. `updateTaskState()` 
does nothing in `PAUSED`, so the next poll returned records again and they went 
to the suspended route, while `isKafkaPaused()` still reported the consumer as 
paused. The same happened to a route started with an open circuit: the 
rebalance paused the new partitions and the listener resumed them right after.
   
   Fix: while the task is `PAUSED` the listener does not run, and that 
iteration is skipped. In that state the partitions are paused and the poll 
returns no records. A resume of the route that comes in the meantime is applied 
on the next iteration, after the listener, so resuming the route still does not 
override a failing check of the pausable EIP. Routes without the pausable EIP 
are not changed.
   
   Not changed here (noted in the JIRA): with `consumersCount` above 1, all 
tasks share one `KafkaConsumerListener`, which only keeps the Kafka consumer of 
the last task that connected.
   
   ## Tests
   
   - New `KafkaPausableConsumerSuspendTest` (`MockConsumer`): a suspended route 
consumes nothing while the check holds and gets the record after the resume; a 
route resumed while the check fails waits for the check; a route started with 
an open circuit consumes nothing. The first and third tests fail on main 
(`Expected: <0> but was: <1>`).
   - `KafkaConsumer*Test` and `KafkaBatching*Test` (1055 tests, including the 
DST seeds) pass.
   - `KafkaPausableConsumerIT` and `KafkaPausableConsumerCircuitBreakerIT` pass 
against a Kafka container.
   
   _Claude Code on behalf of Claus Ibsen (davsclaus)_
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
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