Skip to content

Commit 2b58f59

Browse files
authored
Merge pull request #48486 from jponge/deps/mutiny-vertx-3.19.1-vertx-4.5.16
Version bumps for Vert.x 4.5.16
2 parents fa4bc4d + c5797e2 commit 2b58f59

File tree

7 files changed

+122
-59
lines changed

7 files changed

+122
-59
lines changed

bom/application/pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
<microprofile-jwt.version>2.1</microprofile-jwt.version>
4747
<microprofile-lra.version>2.0.1</microprofile-lra.version>
4848
<microprofile-openapi.version>4.0.2</microprofile-openapi.version>
49-
<smallrye-common.version>2.12.0</smallrye-common.version>
49+
<smallrye-common.version>2.12.2</smallrye-common.version>
5050
<smallrye-config.version>3.13.2</smallrye-config.version>
5151
<smallrye-health.version>4.2.0</smallrye-health.version>
5252
<smallrye-metrics.version>4.0.0</smallrye-metrics.version>
@@ -57,7 +57,7 @@
5757
<smallrye-context-propagation.version>2.2.1</smallrye-context-propagation.version>
5858
<smallrye-reactive-streams-operators.version>1.0.13</smallrye-reactive-streams-operators.version>
5959
<smallrye-reactive-types-converter.version>3.0.3</smallrye-reactive-types-converter.version>
60-
<smallrye-mutiny-vertx-binding.version>3.19.0</smallrye-mutiny-vertx-binding.version>
60+
<smallrye-mutiny-vertx-binding.version>3.19.1</smallrye-mutiny-vertx-binding.version>
6161
<smallrye-reactive-messaging.version>4.28.0</smallrye-reactive-messaging.version>
6262
<smallrye-stork.version>2.7.3</smallrye-stork.version>
6363
<jakarta.activation.version>2.1.3</jakarta.activation.version>
@@ -111,7 +111,7 @@
111111
<wildfly-elytron.version>2.6.4.Final</wildfly-elytron.version>
112112
<jboss-marshalling.version>2.2.3.Final</jboss-marshalling.version>
113113
<jboss-threads.version>3.9.1</jboss-threads.version>
114-
<vertx.version>4.5.14</vertx.version>
114+
<vertx.version>4.5.16</vertx.version>
115115
<httpclient.version>4.5.14</httpclient.version>
116116
<httpcore.version>4.4.16</httpcore.version>
117117
<httpasync.version>4.1.5</httpasync.version>

docs/src/main/asciidoc/messaging.adoc

Lines changed: 19 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -656,21 +656,18 @@ This means that context captured through Emitters won't be propagated to the out
656656
This behaviour can be configured using `quarkus.messaging.connector-context-propagation` configuration property, by listing the context types to propagate.
657657
For example `quarkus.messaging.connector-context-propagation=CDI` will only propagate the CDI context.
658658

659-
<<internal-channels>> however do propagate the context, as they are part of the same application and the context is not lost.
659+
=== Context Propagation with Emitters
660660

661-
For example, you might want to propagate the caller context from an incoming HTTP request to the message processing stage.
662-
For emitters, it is recommended to use the `MutinyEmitter`, as it exposes methods such as `sendAndAwait` that makes sure to wait until a message processing is terminated.
661+
When using messaging emitters, the context is not propagated by default.
663662

664-
[WARNING]
665-
====
666-
The execution context to which the RequestScoped context is bound, in the previous example the REST call, controls the lifecycle of the context.
667-
This means that when the REST call is completed the RequestScoped context is destroyed.
668-
Therefore, you need to make sure that your processing or message dispatch is completed before the REST call completes.
663+
In some scenarios, you might want to propagate the caller context to the message processing stage, using <<internal-channels,internal channels>>.
669664

670-
For more information check the xref:context-propagation.adoc#context-propagation-for-cdi[Context Propagation] guide.
671-
====
665+
Quarkus provides `ContextualEmitter`, a drop in replacement for `MutinyEmitter` and `Emitter`, that allows you to propagate the context when sending messages.
666+
You can use the context propagation annotation `@CurrentThreadContext` to configure the contexts that will be propagated from an _emitter_ method.
667+
The annotation configures the contexts that will be captured and propagated from that method,
668+
and needs to be present on the propagator method, i.e. the caller of the emitter, not the processing method.
672669

673-
For example, let `RequestScopedBean` a request-scoped bean, `MutinyEmitter` can be used to dispatch messages locally through the internal channel `app`:
670+
Let `RequestScopedBean` a request-scoped bean, `ContextualEmitter` can be used to dispatch messages locally through the internal channel `app`:
674671

675672
[source, java]
676673
----
@@ -681,19 +678,15 @@ import jakarta.ws.rs.Path;
681678
import jakarta.ws.rs.core.MediaType;
682679
683680
import org.eclipse.microprofile.reactive.messaging.Channel;
684-
import io.smallrye.reactive.messaging.MutinyEmitter;
685681
686682
import io.quarkus.logging.Log;
687-
688-
import io.smallrye.mutiny.Uni;
689-
import io.vertx.core.Context;
690-
import io.vertx.core.Vertx;
683+
import io.quarkus.smallrye.reactivemessaging.runtime.ContextualEmitter;
691684
692685
@Path("/")
693686
public class Resource {
694687
695688
@Channel("app")
696-
MutinyEmitter<String> emitter;
689+
ContextualEmitter<String> emitter;
697690
698691
@Inject
699692
RequestScopedBean requestScopedBean;
@@ -736,16 +729,7 @@ public class Processor {
736729
}
737730
----
738731

739-
[TIP]
740-
====
741-
You can use the context propagation annotation `@CurrentThreadContext` to configure the contexts that will be propagated from an _emitter_ method.
742-
The annotation configures the contexts that will be captured and propagated from that method,
743-
and needs to be present on the propagator method, i.e. the caller of the emitter, not the processing method.
744-
745-
Because Quarkus Messaging dispatches messages on link:https://smallrye.io/smallrye-reactive-messaging/latest/concepts/message-context[message context],
746-
propagation plans with cleared or not propagated contexts can lead to race conditions using emitters in <<internal-channels,internal channels>>.
747-
It is recommended to use `ContextualEmitter` to ensure the context propagation plan is applied correctly.
748-
732+
You can also use the `@CurrentThreadContext` annotation to control which contexts are propagated.
749733
The following example shows how to avoid propagating any context to the message processing stage:
750734

751735
[source, java]
@@ -785,7 +769,15 @@ public class Resource {
785769
}
786770
----
787771

772+
[WARNING]
788773
====
774+
The execution context to which the RequestScoped context is bound, in the previous example the REST call, controls the lifecycle of the context.
775+
This means that when the REST call is completed the RequestScoped context is destroyed.
776+
Therefore, you need to make sure that your processing or message dispatch is completed before the REST call completes.
777+
778+
For more information check the xref:context-propagation.adoc#context-propagation-for-cdi[Context Propagation] guide.
779+
====
780+
789781

790782
=== Request Context Activation
791783

extensions/smallrye-reactive-messaging/runtime/src/main/java/io/quarkus/smallrye/reactivemessaging/runtime/ContextualEmitterImpl.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@
1818
import io.smallrye.reactive.messaging.providers.extension.AbstractEmitter;
1919
import io.smallrye.reactive.messaging.providers.i18n.ProviderLogging;
2020
import io.smallrye.reactive.messaging.providers.locals.ContextAwareMessage;
21+
import io.smallrye.reactive.messaging.providers.locals.LocalContextMetadata;
2122
import io.vertx.core.Context;
2223
import io.vertx.core.Vertx;
24+
import io.vertx.core.impl.ContextInternal;
2325

2426
public class ContextualEmitterImpl<T> extends AbstractEmitter<T> implements ContextualEmitter<T> {
2527

@@ -67,7 +69,7 @@ public <M extends Message<? extends T>> Uni<Void> sendMessage(M msg) {
6769
// during the emission.
6870
Context context = Vertx.currentContext();
6971
// context propagation capture and duplicate the context
70-
var msgUni = Uni.createFrom().item(() -> ContextAwareMessage.withContextMetadata((Message<? extends T>) msg));
72+
var msgUni = Uni.createFrom().item(() -> createContextualMessage((Message<? extends T>) msg, context));
7173
if (context != null) {
7274
msgUni = msgUni.emitOn(r -> context.runOnContext(x -> r.run()));
7375
}
@@ -97,6 +99,19 @@ public <M extends Message<? extends T>> Uni<Void> sendMessage(M msg) {
9799
}
98100
}
99101

102+
private static <T, M extends Message<T>> Message<T> createContextualMessage(M msg, Context context) {
103+
if (context == null) {
104+
// No context, return the message with a new context as is.
105+
return ContextAwareMessage.withContextMetadata(msg);
106+
} else {
107+
// create new context and copy local data from previous context
108+
ContextInternal internal = (ContextInternal) context;
109+
ContextInternal newCtx = internal.duplicate();
110+
newCtx.localContextData().putAll(internal.localContextData());
111+
return msg.addMetadata(new LocalContextMetadata(newCtx));
112+
}
113+
}
114+
100115
public static <T> Uni<T> emitter(Consumer<UniEmitter<? super T>> emitter) {
101116
return Infrastructure.onUniCreation(new UniCreateWithEmitter<>(emitter));
102117
}

extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/filters/AbstractResponseWrapper.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,11 @@ public HttpServerResponse endHandler(Handler<Void> handler) {
169169
return this;
170170
}
171171

172+
@Override
173+
public Future<Void> writeHead() {
174+
return delegate.writeHead();
175+
}
176+
172177
@Override
173178

174179
public Future<Void> write(String chunk, String enc) {

independent-projects/resteasy-reactive/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757

5858
<mutiny.version>2.9.1</mutiny.version>
5959
<smallrye-common.version>2.12.0</smallrye-common.version>
60-
<vertx.version>4.5.14</vertx.version>
60+
<vertx.version>4.5.16</vertx.version>
6161
<rest-assured.version>5.5.5</rest-assured.version>
6262
<commons-logging-jboss-logging.version>1.0.0.Final</commons-logging-jboss-logging.version>
6363
<jackson-bom.version>2.19.1</jackson-bom.version>
@@ -66,7 +66,7 @@
6666
<yasson.version>3.0.4</yasson.version>
6767
<jakarta.json.bind-api.version>3.0.1</jakarta.json.bind-api.version>
6868
<awaitility.version>4.3.0</awaitility.version>
69-
<smallrye-mutiny-vertx-core.version>3.19.0</smallrye-mutiny-vertx-core.version>
69+
<smallrye-mutiny-vertx-core.version>3.19.1</smallrye-mutiny-vertx-core.version>
7070
<reactive-streams.version>1.0.4</reactive-streams.version>
7171
<mockito.version>5.18.0</mockito.version>
7272
<wiremock.version>3.13.1</wiremock.version>

independent-projects/vertx-utils/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
<properties>
1919
<jboss-logging.version>3.6.1.Final</jboss-logging.version>
20-
<vertx.version>4.5.14</vertx.version>
20+
<vertx.version>4.5.16</vertx.version>
2121
</properties>
2222

2323
<dependencies>

integration-tests/reactive-messaging-context-propagation/src/test/java/io/quarkus/it/kafka/KafkaContextPropagationTest.java

Lines changed: 76 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
public class KafkaContextPropagationTest {
2323

2424
@Nested
25+
// FlowerResource
2526
class ContextNotPropagated {
2627
@Test
2728
void testNonBlocking() {
@@ -131,6 +132,7 @@ void testVirtualThreadUni() {
131132
}
132133

133134
@Nested
135+
// FlowerContextualResource
134136
class ContextPropagated {
135137
@Test
136138
void testNonBlocking() {
@@ -192,63 +194,112 @@ void testVirtualThreadUni() {
192194
}
193195

194196
@Nested
195-
class MutinyContextPropagated {
197+
// FlowerMutinyResource
198+
class MutinyContextNotPropagated {
196199
@Test
197200
void testNonBlocking() {
198-
given().body("rose").post("/flowers/mutiny").then().statusCode(204);
199-
given().body("peony").post("/flowers/mutiny").then().statusCode(204);
200-
given().body("daisy").post("/flowers/mutiny").then().statusCode(204);
201+
given().body("rose").post("/flowers/mutiny").then()
202+
.statusCode(500)
203+
.body(assertBodyRequestScopedContextWasNotActive());
204+
given().body("peony").post("/flowers/mutiny").then()
205+
.statusCode(500)
206+
.body(assertBodyRequestScopedContextWasNotActive());
207+
given().body("daisy").post("/flowers/mutiny").then()
208+
.statusCode(500)
209+
.body(assertBodyRequestScopedContextWasNotActive());
201210
}
202211

203212
@Test
204213
void testNonBlockingUni() {
205-
given().body("rose").post("/flowers/mutiny/uni").then().statusCode(204);
206-
given().body("peony").post("/flowers/mutiny/uni").then().statusCode(204);
207-
given().body("daisy").post("/flowers/mutiny/uni").then().statusCode(204);
214+
given().body("rose").post("/flowers/mutiny/uni").then()
215+
.statusCode(500)
216+
.body(assertBodyRequestScopedContextWasNotActive());
217+
given().body("peony").post("/flowers/mutiny/uni").then()
218+
.statusCode(500)
219+
.body(assertBodyRequestScopedContextWasNotActive());
220+
given().body("daisy").post("/flowers/mutiny/uni").then()
221+
.statusCode(500)
222+
.body(assertBodyRequestScopedContextWasNotActive());
208223
}
209224

210225
@Test
211226
void testBlocking() {
212-
given().body("rose").post("/flowers/mutiny/blocking").then().statusCode(204);
213-
given().body("peony").post("/flowers/mutiny/blocking").then().statusCode(204);
214-
given().body("daisy").post("/flowers/mutiny/blocking").then().statusCode(204);
227+
given().body("rose").post("/flowers/mutiny/blocking").then()
228+
.statusCode(500)
229+
.body(assertBodyRequestScopedContextWasNotActive());
230+
given().body("peony").post("/flowers/mutiny/blocking").then()
231+
.statusCode(500)
232+
.body(assertBodyRequestScopedContextWasNotActive());
233+
given().body("daisy").post("/flowers/mutiny/blocking").then()
234+
.statusCode(500)
235+
.body(assertBodyRequestScopedContextWasNotActive());
215236
}
216237

217238
@Test
218239
void testBlockingUni() {
219-
given().body("rose").post("/flowers/mutiny/uni/blocking").then().statusCode(204);
220-
given().body("peony").post("/flowers/mutiny/uni/blocking").then().statusCode(204);
221-
given().body("daisy").post("/flowers/mutiny/uni/blocking").then().statusCode(204);
240+
given().body("rose").post("/flowers/mutiny/uni/blocking").then()
241+
.statusCode(500)
242+
.body(assertBodyRequestScopedContextWasNotActive());
243+
given().body("peony").post("/flowers/mutiny/uni/blocking").then()
244+
.statusCode(500)
245+
.body(assertBodyRequestScopedContextWasNotActive());
246+
given().body("daisy").post("/flowers/mutiny/uni/blocking").then()
247+
.statusCode(500)
248+
.body(assertBodyRequestScopedContextWasNotActive());
222249
}
223250

224251
@Test
225252
void testBlockingNamed() {
226-
given().body("rose").post("/flowers/mutiny/blocking-named").then().statusCode(204);
227-
given().body("peony").post("/flowers/mutiny/blocking-named").then().statusCode(204);
228-
given().body("daisy").post("/flowers/mutiny/blocking-named").then().statusCode(204);
253+
given().body("rose").post("/flowers/mutiny/blocking-named").then()
254+
.statusCode(500)
255+
.body(assertBodyRequestScopedContextWasNotActive());
256+
given().body("peony").post("/flowers/mutiny/blocking-named").then()
257+
.statusCode(500)
258+
.body(assertBodyRequestScopedContextWasNotActive());
259+
given().body("daisy").post("/flowers/mutiny/blocking-named").then()
260+
.statusCode(500)
261+
.body(assertBodyRequestScopedContextWasNotActive());
229262
}
230263

231264
@Test
232265
void testBlockingNamedUni() {
233-
given().body("rose").post("/flowers/mutiny/uni/blocking-named").then().statusCode(204);
234-
given().body("peony").post("/flowers/mutiny/uni/blocking-named").then().statusCode(204);
235-
given().body("daisy").post("/flowers/mutiny/uni/blocking-named").then().statusCode(204);
266+
given().body("rose").post("/flowers/mutiny/uni/blocking-named").then()
267+
.statusCode(500)
268+
.body(assertBodyRequestScopedContextWasNotActive());
269+
given().body("peony").post("/flowers/mutiny/uni/blocking-named").then()
270+
.statusCode(500)
271+
.body(assertBodyRequestScopedContextWasNotActive());
272+
given().body("daisy").post("/flowers/mutiny/uni/blocking-named").then()
273+
.statusCode(500)
274+
.body(assertBodyRequestScopedContextWasNotActive());
236275
}
237276

238277
@Test
239278
@EnabledForJreRange(min = JRE.JAVA_21)
240279
void testVirtualThread() {
241-
given().body("rose").post("/flowers/mutiny/virtual-thread").then().statusCode(204);
242-
given().body("peony").post("/flowers/mutiny/virtual-thread").then().statusCode(204);
243-
given().body("daisy").post("/flowers/mutiny/virtual-thread").then().statusCode(204);
280+
given().body("rose").post("/flowers/mutiny/virtual-thread").then()
281+
.statusCode(500)
282+
.body(assertBodyRequestScopedContextWasNotActive());
283+
given().body("peony").post("/flowers/mutiny/virtual-thread").then()
284+
.statusCode(500)
285+
.body(assertBodyRequestScopedContextWasNotActive());
286+
given().body("daisy").post("/flowers/mutiny/virtual-thread").then()
287+
.statusCode(500)
288+
.body(assertBodyRequestScopedContextWasNotActive());
244289
}
245290

246291
@Test
247292
@EnabledForJreRange(min = JRE.JAVA_21)
248293
void testVirtualThreadUni() {
249-
given().body("rose").post("/flowers/mutiny/uni/virtual-thread").then().statusCode(204);
250-
given().body("peony").post("/flowers/mutiny/uni/virtual-thread").then().statusCode(204);
251-
given().body("daisy").post("/flowers/mutiny/uni/virtual-thread").then().statusCode(204);
294+
given().body("rose").post("/flowers/mutiny/uni/virtual-thread").then()
295+
.statusCode(500)
296+
.body(assertBodyRequestScopedContextWasNotActive());
297+
given().body("peony").post("/flowers/mutiny/uni/virtual-thread").then()
298+
.statusCode(500)
299+
.body(assertBodyRequestScopedContextWasNotActive());
300+
given().body("daisy").post("/flowers/mutiny/uni/virtual-thread").then()
301+
.statusCode(500)
302+
.body(assertBodyRequestScopedContextWasNotActive());
252303
}
253304
}
254305

0 commit comments

Comments
 (0)