Package io.quarkus.vertx
Annotation Type ConsumeEvent
-
@Target(METHOD) @Retention(RUNTIME) public @interface ConsumeEvent
Marks a business method to be automatically registered as a Vertx message consumer.The method must accept exactly one parameter. If it accepts
Message
orMessage
then the return type must be void. For any other type theMessage.body()
is passed as the parameter value and the method may return an object that is passed toMessage.reply(Object)
, either directly or viaCompletionStage.thenAccept(java.util.function.Consumer)
in case of the method returns a completion stage.@ApplicationScoped class MyService { @ConsumeEvent("echo") String echo(String msg) { return msg.toUpperCase(); } @ConsumeEvent("echoMessage") void echoMessage(Message
msg) { msg.reply(msg.body().toUpperCase()); } @ConsumeEvent(value = "echoMessageBlocking", blocking = true) void echoMessageBlocking(Message msg) { msg.reply(msg.body().toUpperCase()); } } The CDI request context is always active during notification of the registered message consumer.
If a method annotated with
ConsumeEvent
throws an exception then:- if a reply handler is set the failure is propagated back to the sender via an
ReplyException
with codeFAILURE_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. {@link io.vertx.core.Vertx#exceptionHandler().}
- See Also:
EventBus
- if a reply handler is set the failure is propagated back to the sender via an
-
-
Field Summary
Fields Modifier and Type Fields Description static int
EXPLICIT_FAILURE_CODE
Failure code used when a message consumer explicitly fails an asynchronous processing.static int
FAILURE_CODE
Failure code used when a message consumer method throws an exception.
-
-
-
-
EXPLICIT_FAILURE_CODE
static final int EXPLICIT_FAILURE_CODE
Failure code used when a message consumer explicitly fails an asynchronous processing. This status is used when the method annotated withConsumeEvent
returns a failedCompletionStage
orUni
.
-
-
Element Detail
-
value
String value
The address the consumer will be registered to. By default, the fully qualified name of the declaring bean class is assumed.- Returns:
- the address
- Default:
- ""
-
-
-
ordered
boolean ordered
- Returns:
true
if the blocking consumption of the event must be ordered, meaning that the method won't be called concurrently. Instead, it serializes all the invocations based on the event order.ordered
must be used in conjunction withblocking=true
or@Blocking
.- See Also:
Vertx.executeBlocking(io.vertx.core.Handler, boolean, io.vertx.core.Handler)
- Default:
- false
-
-
-
codec
Class<? extends io.vertx.core.eventbus.MessageCodec> codec
- Returns:
null
if it should use a default MessageCodec- See Also:
LocalEventBusCodec
- Default:
- io.quarkus.vertx.LocalEventBusCodec.class
-
-