You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/src/main/asciidoc/messaging.adoc
+95
Original file line number
Diff line number
Diff line change
@@ -562,6 +562,7 @@ public class StreamProcessor {
562
562
}
563
563
----
564
564
565
+
[[execution_model]]
565
566
== Execution Model
566
567
567
568
Quarkus Messaging sits on top of the xref:quarkus-reactive-architecture.adoc#engine[reactive engine] of Quarkus and leverages link:{eclipse-vertx}[Eclipse Vert.x] to dispatch messages for processing.
@@ -634,6 +635,100 @@ Depending on the broker technology, this can be useful to increase the applicati
634
635
while still preserving the partial order of messages received in different copies.
635
636
This is the case, for example, for Kafka, where multiple consumers can consume different topic partitions.
636
637
638
+
== Context Propagation
639
+
640
+
In Quarkus Messaging, the default mechanism for propagating context between different processing stages is the
This provides a consistent way to pass context information along with the message as it flows through different stages.
643
+
644
+
=== Interaction with Mutiny and MicroProfile Context Propagation
645
+
646
+
Mutiny, which is the foundation of reactive programming in Quarkus, is integrated with the MicroProfile Context Propagation.
647
+
This integration enables automatic capturing and restoring of context across asynchronous boundaries.
648
+
To learn more about context propagation in Quarkus and Mutiny, refer to the xref:context-propagation.adoc[Context Propagation] guide.
649
+
650
+
However, Quarkus Messaging needs to coordinate multiple asynchronous boundaries.
651
+
This is why the default context propagation can result in unexpected behavior in some cases, especially using `Emitters`.
652
+
653
+
To ensure consistent behavior, Quarkus Messaging disables the propagation of any context during message dispatching, through internal channels or connectors.
654
+
This means that Emitters won't capture the caller context, and incoming channels won't dispatch messages by activating a context (ex. the request context).
655
+
656
+
For example, you might want to propagate the caller context from an incoming HTTP request to the message processing stage.
657
+
For emitters, instead of using the regular `Emitter` or `MutinyEmitter`, you can inject the `ContextualEmitter` to make sure the message captures the caller context.
658
+
This ensures consistent and predictable behaviour by relying on the message context handling provided by the framework.
659
+
660
+
For example, let `RequestScopedBean` a request-scoped bean, `ContextualEmitter` can be used to dispatch messages locally through the internal channel `app`:
Copy file name to clipboardExpand all lines: extensions/smallrye-reactive-messaging/deployment/src/main/java/io/quarkus/smallrye/reactivemessaging/deployment/ReactiveMessagingBuildTimeConfig.java
+7
Original file line number
Diff line number
Diff line change
@@ -27,4 +27,11 @@ public interface ReactiveMessagingBuildTimeConfig {
27
27
@WithName("auto-connector-attachment")
28
28
@WithDefault("true")
29
29
booleanautoConnectorAttachment();
30
+
31
+
/**
32
+
* Whether to enable the RequestScope context on a message context
Copy file name to clipboardExpand all lines: extensions/smallrye-reactive-messaging/deployment/src/main/java/io/quarkus/smallrye/reactivemessaging/deployment/SmallRyeReactiveMessagingProcessor.java
0 commit comments