Hi Viloms, Thanks for reporting the issue, I thought it was related to some refactor we have been doing lately wrt Java Error, but it is not the case. The stop comes from CAMEL-21769, where rethrowing the Error was deliberate, so stopping the consumer is intentional and your approach fits. What isn't intentional is leaving the route "Started", the health check UP and the scheduler reported as running.
Your fix is welcome, so please go ahead and open the JIRA issue and the PR. A few points for the patch: 1. concurrentConsumers > 1: a successful poll on another thread resets errorCounter and lastError, and so does a greedy poll. The health check would go back to UP with one poller fewer. Please keep a sticky marker for the fatal Error that only a stop/start of the consumer clears, and let the health check report DOWN on it. 2. isSchedulerStarted(): doStop() and unscheduleTask() use it to decide whether to cancel and clear the futures, and startScheduler() only schedules when that list is empty. If it returns false once the tasks are done, a restart with a shared scheduledExecutorService would never poll again. Please keep those internal checks on the list of futures. 3. The log line in run(): please say that polling has stopped until the route is restarted. 4. Docs: please add a short entry to the 4.24 upgrade guide, because the health check now reports DOWN where it reported UP. Please also add a line to the "An Error thrown by a processor" section of error-handler.adoc. Note there that an OutOfMemoryError or StackOverflowError thrown in the route leaves that exchange inflight, so a route restart waits for the shutdown timeout. 5. Tests: please cover an Error thrown by poll() and one thrown by the route, concurrentConsumers=2, and a stop/start that polls again. I found the same pattern in a few other consumers (timer, seda and others). I'll track those separately. Thanks, Federico Il giorno lun 23 nov 2026 alle ore 16:05 Vilmos Szabó-Nagy < [email protected]> ha scritto: > Hi all, > > One of our aws2-s3 routes hit an OutOfMemoryError while processing an > exchange on its poll thread. After that it never polled again. The > route still reported Started, the consumer health check stayed > UP, and only our own monitoring eventually noticed. We can fix the OOM > case with -XX:+ExitOnOutOfMemoryError, but any other Error > (StackOverflowError, LinkageError, an OOM thrown by library code) > still > kills the consumer without any signal. > > What happens (4.23.0, same on main): > - ScheduledPollConsumer.doRun() catches only Exception. run() logs the > Error and rethrows it. > - ScheduledThreadPoolExecutor stores it in the task's future and never > reschedules the task. Nothing in DefaultScheduledPollConsumerScheduler > checks those futures, and isSchedulerStarted() still returns > true. > - errorCounter/lastError are never updated, so > ScheduledPollConsumerHealthCheck stays UP. > > Is this intentional? If not, we'd like to send a fix. We think > stopping the consumer after an Error is right, since nobody can tell > what state the JVM is in after one. The problem is only that the > failure isn't visible. Our proposal is a small change in doRun(): > - catch Error next to the existing catch (Exception e), as the poll's > cause, skipping the ExceptionHandler and pollStrategy.rollback(); > - let the existing bookkeeping run, which sets lastError and > increments errorCounter; > - then rethrow, so run() still logs it and the task still ends. > > Since no later poll can reset the counters, the health check stays > DOWN until the route is restarted, and orchestrators can then restart > the instance. Optionally, isSchedulerStarted() could also check > whether its futures are still running. > > Would you be open to this? We have a patch with tests ready and are > happy to open the JIRA issue and the PR. > > Thanks, > Vilmos >
