javaeventsjakarta-eecdicdi-2.0

Why Event.fireAsync() requires an @ObservesAsync annotation?


In CDI 2.0 one can fire an event asynchronously by calling Event.fireAsync() and then listen to this event by with a @ObservesAsync annotated listener.

Why do we need both Event.firesAsync() and @ObservesAsync?


Solution

  • A very good question indeed, here is a bit of insight.

    CDI EG (expert group) decided against mixing those two for several reasons:

    Other advantages of the current model I can think of: