Working Group Proposal - Unified Event Bus #53202
Replies: 4 comments 10 replies
-
|
@mkouba, @ozangunalp can you review? |
Beta Was this translation helpful? Give feedback.
-
I do not think that we want to propagate the CDI request context. As @Ladicek pointed out - Vert.x event bus can be used to escape the context boundaries and I believe that we should preserve this behavior for the new API. Security and tracing should be propagated. I'm not so sure about MDC.
Hm, I believe that our initial implementation should be based on Vert.x event bus, so yes, the Vert.x core could be required. @cescoffier Other than that 👍! |
Beta Was this translation helpful? Give feedback.
-
|
The working group has now officially started. See WG - Unified Event Bus (view). |
Beta Was this translation helpful? Give feedback.
-
|
This piqued my interest, so I started looking into how things works currently and what we could do. Anyway, I think a good way would be to leverage existing Vert.x event bus and just build an API on top of it to allow users to sidestep the String based address with types. We'd of course need qualifiers to be able to support observing the same type via various consumers. In order to give some shape to my thoughts, I cobbled together a PoC which can be seen here - manovotn#2 This is obviously just one way to handle it and I am not saying it is the best. Just wanted to share the way I thought about it;, we could avoid using Vert.x event bus altogether if we wanted to 🤷 |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Objective
Design and implement a new Quarkus-native event API that is type-safe, supports multiple messaging patterns (pub/sub, point-to-point, request-response), automatically propagates context, and works without a Vert.x (HTTP) dependency, providing a unified programming model for decoupled component interaction.
The Problem
Quarkus developers who want application components to interact in a decoupled fashion, with no compile-time dependency between interacting components, face a fragmented landscape of three overlapping mechanisms, each with significant limitations.
This problem becomes even more pressing with the rise of modular monolith (modulith) architectures, in which a reliable in-process event bus serves as the primary integration backbone between modules.
1. CDI Events: Type-Safe but Limited
Pros:
Cons:
Uni-returning observers run on the event loop; qualifier matching complexity withBeanManager#fireEvent()deriving types from runtime class)Async observers (CDI 2.0) make things worse:
@ObservesAsync+Event#fireAsync())2. Vert.x Event Bus: Flexible but Unsafe
Pros:
Cons:
@ConsumeEventhandlers get a new CDI request context (not propagated from sender)3. In-Memory Quarkus Messaging: The wrong tool
SmallRye Reactive Messaging's in-memory transport serves a similar purpose for channel-based communication, adding yet another option to the mix. Developers must understand where in-memory channels, CDI events, and Vert.x event bus each apply.
The Result
The Proposed Solution
A New Quarkus-Native Event API
Design a new event API built specifically for Quarkus with the following properties:
Type-safe routing: The event type is the address. No string-based addressing. The API leverages Java's type system for event routing, similar to CDI events but without the CDI specification's compatibility constraints.
Multi-pattern support: A single API supports:
Automatic context propagation: Security, tracing, MDC, and CDI contexts (except the request scope) propagate automatically across event-delivery boundaries, for both synchronous and asynchronous handlers.
No Vert.x HTTP dependency: The API works without
vertx-http(Vert.x core may be required - still need to be discussed), making it usable in CLI applications and other non-HTTP scenarios.Usable by both users and extension developers: The API is designed for application developers writing business logic and for extension developers building framework-level integrations.
Relationship with Existing Mechanisms
CDI Events: Continue to exist for CDI-specification-level interoperability. The new API does not replace
@Observesfor standard CDI use cases but provides a superior Quarkus-native alternative for application-level eventing.Vert.x Event Bus: The
@ConsumeEventannotation and direct Vert.x event bus usage will be deprecated in favor of the new API. A migration path will be provided.In-Memory Quarkus Messaging: The relationship is clearly defined: Quarkus/Reactive Messaging is for stream processing and external messaging integration; the new event API is for in-process decoupled component interaction.
Leverage the Vert.x 5 Migration Window
The Quarkus 4/Vert.x 5 migration provides a natural opportunity for redesign. Since
@ConsumeEventand Vert.x event bus usage patterns will need updates regardless, this is the right time to introduce a unified replacement.Definition of Done
@ConsumeEventand Vert.x event bus to the new APIScope of Work
In Scope
@ConsumeEvent/ Vert.x event busOut of Scope
Organizing the Work
Communication
#wg-unified-eventsTimeline
Existing Issues
Beta Was this translation helpful? Give feedback.
All reactions