What's the best way to invoke Uni in an async observer? It would be great if I could just return Uni but unfortunately that doesn't work.
void observe(@ObservesAsync MyEvent event) {
Uni<Object> task;
}
As mentioned by @ladicek, you can:
CompletionStage
void observe(@Observes MyEvent event) {
Uni<Void> uni = ...;
uni.await().indefinitely();
}
void observe(@Observes MyEvent event) {
Uni<Void> uni = ...;
uni.subscribeAsCompletionStage(); // Fire and forget, no error reporting
}
Or:
void observe(@Observes MyEvent event) {
Uni<Void> uni = ...;
uni.subscribe().with(success -> ..., failure -> log(failure));
}
CompletionStage
CompletionStage<Void> observe(@ObservesAsync MyEvent event) {
Uni<Void> uni = ...;
return uni.subscribeAsCompletionStage();
}