Details

    • Type: Feature Request
    • Status: Resolved (View Workflow)
    • Priority: Major
    • Resolution: Done
    • Affects Version/s: 1.2.Final
    • Fix Version/s: 2.0-EDR1
    • Component/s: Events
    • Labels:
      None

      Description

      We should allow a way to fire event asynchronously. This mechanism should leverage new async API in JDK8 especially the CompletionStage interface.
      Our proposal is:

      1. Add fireAsync() method to Event and BeanManager

      Signature of the method on Event<T> would be

      <U extends T> CompletionStage<U> fireAsync(U event);
      

      Signature on BeanManager would be

      <T> CompletionStage<T> fireAsyncEvent(T event, Annotation... qualifiers)
      

      2. Add an asyncSupported() member to @Observes

      For backward compatibility reason the possibility to invoke an observer asynchronously should be let to the observer (legacy observers should be called synchronously). We propose to add the boolean asyncSupported() member with the false default value to support this backward compatibility aspect.
      So to be notified asynchronously an observer should have asyncSupported member to true. otherwise it will be called synchronously.

      3. Observer bound to a transaction phase

      these observer will be invoked in the right transaction phase but asynchronously

      4. Event Ordering

      Should we decide to add events ordering in CDI 2.0, the order will be keep in asynchronous observer notification. If there are a mix of synchronous and asynchronous observer, asynchronous will be called first in order, then synchronous in their order (async has priority on sync).

      5. Event state (payload mutability)

      We'll keep payload mutability with async events (but should explicitly specify it). That means that we should guarantee the event state consistency between observers and in case of ordered observers the fact that observer N+1 get the event state at the end of observer N.

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  antoinesabot-durand Antoine Sabot-Durand
                  Reporter:
                  antoinesabot-durand Antoine Sabot-Durand
                • Votes:
                  6 Vote for this issue
                  Watchers:
                  12 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: