allthingssecurity opened a new pull request, #30987: URL: https://github.com/apache/camel/pull/30987
# Description [CAMEL-27602](https://issues.apache.org/jira/browse/CAMEL-27602) Fixes the two points of the ticket, found while the option descriptions of camel-event were improved for CAMEL-23832 (#30942). I checked both against main first; both are real, and point 2 was a bit worse than the ticket says. 1. **backpressurePolicy=Fail only dropped the event** (fixed). With `async=true` and a full queue, the consumer threw an `IllegalStateException` from `notify()`. Camel notifies the event notifiers through `EventHelper`, which logs and ignores any exception of a notifier, so Fail behaved like Drop plus a WARN log with a stack trace per lost event. The ticket asked to decide what Fail should mean; I took its first suggestion: the consumer now drops the event and passes the `IllegalStateException` to its exception handler. By default that logs at WARN, as before, but now the usual consumer options work: with `bridgeErrorHandler=true` the error handler of the route handles it, and a custom `exceptionHandler` sees it. The option description, the `BackpressurePolicy` javadoc and the doc page say this. The only other change: code that calls `ManagementStrategy.notify()` itself (for a custom event) no longer gets the exception thrown back. With `bridgeErrorHandler=true` the report is an exchange that fires exchange events of its own, in the same thread. With `Exchange*` and no include filter (the Fail example of the doc page) the consumer accepts them, they do not fit in the full queue either, and each one would be reported again, until a `StackOverflowError`. A thread local guard drops the events fired while the consumer reports a full queue, when they do not fit, without another report. Events that fit are queued as usual. The doc page says so. The 4.24 upgrade guide has a short entry for the changed Fail behaviour. 2. **event:ExchangeAsyncProcessingStarted never received an event** (fixed). `configureEventNotifier()` had no case for this deprecated type, so the exchange events stayed ignored. In addition `EventNotifierSupport` ignores this type by default (`ignoreExchangeAsyncProcessingStartedEvents` is true), so the type was never received, also not together with `Exchange*` as the ticket thought. The new case turns both flags on, but only when the endpoint names the type. A wildcard such as `Exchange*` or `*` still does not get these events, so the routes that use a wildcard today do not suddenly get one more event per asynchronous step. The doc page says so. I did not reject the type at endpoint creation (the other option of the ticket), as that would break routes that name it today. Generated files: the component JSON, its catalog copy, the catalog copy of the doc page and `CamelEventEndpointBuilderFactory` of the endpoint DSL are regenerated (only the backpressurePolicy description changes). Tests: - `EventBackpressureFailTest`: with one consumer thread blocked and a queue of size 1, the event that does not fit goes to the exception handler of the endpoint as an `IllegalStateException`, and the two other events are routed. - `EventBackpressureFailBridgeTest`: `event:Exchange*?async=true&backpressurePolicy=Fail&bridgeErrorHandler=true` with one blocked consumer thread and a queue of size 1. The reports reach the error handler of the route, and their own events are not reported again (fewer than 50 reports for two exchanges). Without the guard the reports recurse until a `StackOverflowError` and the test times out after 60 s. - `EventAsyncProcessingStartedTest`: `event:ExchangeAsyncProcessingStarted` gets the event, and `event:Exchange*` in the same context does not. All three fail without the fix and pass with it, 5 runs in a row. The camel-event unit tests pass: 42 run, 0 failures, 0 errors. This branch overlaps #30942 in meaning, not only in files: its new `backpressurePolicy` description says "Fail throws an exception, which Camel logs at WARN and ignores, so the event is lost", which is no longer true with this change. Whichever of the two is merged second needs that sentence adjusted (and the files regenerated). Known limit: the guard works per thread. If the error handler hands the exchange to another thread (for example a dead letter channel to `seda`) and the consumer listens to `Exchange*` without an exclude, the events of that thread are reported again while the queue stays full. Exclude that route (or its events) from the consumer in such a setup. # Target - [x] I checked that the commit is targeting the correct branch (Camel 4 uses the `main` branch) # Tracking - [x] If this is a large change, bug fix, or code improvement, I checked there is a [JIRA issue](https://issues.apache.org/jira/browse/CAMEL) filed for the change (usually before you start working on it): [CAMEL-27602](https://issues.apache.org/jira/browse/CAMEL-27602). # Apache Camel coding standards and style - [x] I checked that each commit in the pull request has a meaningful subject line and body. - [ ] I have run `mvn clean install -DskipTests` locally from root folder and I have committed all auto-generated changes. (I built camel-event, which regenerated the component JSON, and ran the camel-package plugin goals for the endpoint and component DSL against the updated catalog. I did not run the full root build.) # AI-assisted contributions - [x] If this PR includes AI-generated code, commits have proper co-authorship attribution (e.g., `Co-authored-by` trailers) and the PR description identifies the AI tool used. This PR was prepared with Claude Code (Claude Opus 5.5). The commit carries a `Co-Authored-By` trailer. _Claude Code on behalf of allthingssecurity_ 🤖 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]
