Skip to content
Advertisement

quarkus @ObservesAsync invoke Uni

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.

JavaScript

Advertisement

Answer

As mentioned by @ladicek, you can:

  1. use a synchronous observer and block until termination
  2. use a synchronous observer and “trigger” the async operation using a fire-and-forget approach
  3. use an async observer (while it’s not strictly async, it just runs on another thread) and produce a CompletionStage

1) synchronous observer and block until termination

JavaScript

2) synchronous observer and trigger the async operation using a fire-and-forget approach

JavaScript

Or:

JavaScript

Async observer and produce a CompletionStage

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement