From 217082ecc50cead2875ac330e4840e3057d2b6d4 Mon Sep 17 00:00:00 2001 From: Martin Kouba Date: Thu, 6 May 2021 16:31:31 +0200 Subject: [PATCH] Vertx ConsumeEvent - document failure handling - resolves #17040 --- docs/src/main/asciidoc/reactive-event-bus.adoc | 7 +++++++ .../src/main/java/io/quarkus/vertx/ConsumeEvent.java | 12 ++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/docs/src/main/asciidoc/reactive-event-bus.adoc b/docs/src/main/asciidoc/reactive-event-bus.adoc index 183d79755e001..63054b79dba1f 100644 --- a/docs/src/main/asciidoc/reactive-event-bus.adoc +++ b/docs/src/main/asciidoc/reactive-event-bus.adoc @@ -211,6 +211,13 @@ public void consume(Message msg) { } ---- +=== Handling Failures + +If a method annotated with `@ConsumeEvent` throws an exception then: + +* if a reply handler is set then the failure is propagated back to the sender via an `io.vertx.core.eventbus.ReplyException` with code `ConsumeEvent#FAILURE_CODE` and the exception message, +* if no reply handler is set then the exception is rethrown (and wrapped in a `RuntimeException` if necessary) and can be handled by the default exception handler, i.e. `io.vertx.core.Vertx#exceptionHandler()`. + == Sending messages Ok, we have seen how to receive messages, let's now switch to the _other side_: the sender. diff --git a/extensions/vertx/runtime/src/main/java/io/quarkus/vertx/ConsumeEvent.java b/extensions/vertx/runtime/src/main/java/io/quarkus/vertx/ConsumeEvent.java index e9a870edb293c..6b440be2fdc3b 100644 --- a/extensions/vertx/runtime/src/main/java/io/quarkus/vertx/ConsumeEvent.java +++ b/extensions/vertx/runtime/src/main/java/io/quarkus/vertx/ConsumeEvent.java @@ -40,11 +40,19 @@ * * *

- * The CDI request context is active during notification of the registered message consumer. + * The CDI request context is always active during notification of the registered message consumer. + *

+ * If a method annotated with {@link ConsumeEvent} throws an exception then: + *

* * @see io.vertx.core.eventbus.EventBus */ -@Target({ METHOD }) +@Target(METHOD) @Retention(RUNTIME) public @interface ConsumeEvent {