Repository navigation
CAMEL-26135: camel-spring - a CamelEvent only goes to the spring-event consumers of the same name - #28576
Conversation
gnodet-bot
left a comment
There was a problem hiding this comment.
LGTM. No issues found.
The fix is minimal and correct: EventEndpoint.onApplicationEvent() now filters CamelEvent instances by comparing the source endpoint name with this.name using Objects.equals (null-safe). Non-CamelEvent application events still broadcast to all consumers as documented.
Pre-fix validation: the new test correctly detects the regression — mock:bar.expectedMessageCount(1) would fail with 2 messages without the fix (bar would receive both the ContextRefreshedEvent and the CamelEvent from spring-event:foo). SpringTestSupport creates a fresh application context per @Test, so there's no state bleed between test methods.
Upgrade guide and both generated JSON catalog copies are properly updated.
This review was generated by an AI agent, Hermès on behalf of @gnodet.
|
🌟 Thank you for your contribution to the Apache Camel project! 🌟 🐫 Apache Camel Committers, please review the following items:
|
|
🧪 CI tested the following changed modules:
🔬 Scalpel shadow comparison — Scalpel: 23 of 708 tested, 25 compile-only — current: 240 all testedMaveniverse Scalpel detected 23 affected modules (current approach: 240). Skip-tests mode would test 23 modules (4 direct + 21 downstream), skip tests for 25 (generated code, meta-modules) Modules only in current approach (217)
Modules Scalpel would test (23)
Modules with tests skipped (25)
Build reactor — dependencies compiled but only changed modules were tested (4 modules, 53.7s total)Total reactor time: 53.7s
Top 20 slowest modules:
|
|
The
The simplest fix is to add the same route to <route>
<from uri="spring-event:bar"/>
<to uri="mock:bar"/>
</route>The change to Claude Code on behalf of davsclaus |
|
Thanks @davsclaus! I added the spring-event:bar route to mistypedPackage.xml. EventRouteTest and MistypedPackageTest now pass locally (4 tests). |
oscerd
left a comment
There was a problem hiding this comment.
Correct bugfix. A spring-event producer wraps a non-ApplicationEvent body in a CamelEvent and publishes it to the Spring ApplicationContext, where every spring-event consumer's onApplicationEvent received it — so a body sent to spring-event:foo also reached from("spring-event:bar"), cross-talk between unrelated endpoints. Skipping a CamelEvent whose source endpoint name doesn't match this endpoint's name (Objects.equals(name, camelEvent.getSource().getName()), null-safe) scopes it correctly, while genuine ApplicationContext events (ContextRefreshedEvent, or an ApplicationEvent body) still broadcast to every consumer — the right line to draw.
The test nails it: spring-event:foo producing → mock:result (from foo) gets the context-refreshed event + the CamelEvent (2), while mock:bar (from bar) gets only the context-refreshed event (1), and both test contexts gain the :bar route. The upgrade guide documents the scoping change.
No blockers.
Claude Code on behalf of oscerd
…t consumers of the same name The consumer now skips a CamelEvent sent by a spring-event producer with another name. Other application events still go to every consumer. Co-authored-by: Claude <noreply@anthropic.com>
MistypedPackageTest extends EventRouteTest and runs the new test with its own routes. Co-authored-by: Claude <noreply@anthropic.com>
350cbb3 to
3934adb
Compare
Description
CAMEL-26135: the name of a
spring-eventendpoint was ignored. A message sent tospring-event:foowas received by everyspring-eventconsumer, alsofrom("spring-event:bar").The producer publishes a non-event body as a
CamelEvent, whose source is the sendingEventEndpoint.EventEndpoint.onApplicationEventnow skips aCamelEventwhose source has another name.Other application events of the
ApplicationContext(such asContextRefreshedEvent, or anApplicationEventbody sent by a producer) still go to every consumer, as the component docs say. I asked about this on the JIRA; happy to change it if a different behavior is wanted.Changes:
EventEndpoint: the name check, and the consumer body description updated (generated JSON and catalog copy updated too)EventRouteTest: a new test with a second route onspring-event:bar; it fails without the fix (mock:bar gets 2 messages) and passes with itTarget
mainbranch)Tracking
Apache Camel coding standards and style
I checked that each commit in the pull request has a meaningful subject line and body.
I have run
mvn clean install -DskipTestslocally from root folder and I have committed all auto-generated changes.AI-assisted contributions
Co-authored-bytrailers) and the PR description identifies the AI tool used.This PR was prepared with the help of Claude (Anthropic), credited with a
Co-authored-bytrailer in the commit.