Uploaded image for project: 'CDI Specification Issues'
  1. CDI Specification Issues
  2. CDI-650

Introduce asynchronous event notification options

    XMLWordPrintable

Details

    • Feature Request
    • Resolution: Done
    • Major
    • 2.0 .Final
    • None
    • None
    • None

    Description

      Currently, it's only possible to provide a custom executor when firing an event asynchronously - see also javax.enterprise.event.Event.fireAsync(U, Executor). It might be useful to provide other implementation-specific options, e.g. notification timeout.

      Therefore, I suggest to introduce NotificationOptions interface:

      public interface NotificationOptions {
          Executor getExecutor();
          // Implementation-specific options
          Object get(String optionName);
      }
      

      and change the method signature to:

      <U extends T> CompletionStage<U>  fireAsync(U event, NotificationOptions options);
      

      In the future, if any implementation-specific configuration proves to be useful and worth standardizing, we may simply add a new method to NotificationOptions, e.g.

      Duration getTimeout();
      

      instead of adding more and more params to Event.fireAsync().

      We could also introduce some convenient static methods on NotificationOptions, e.g.:

      void fireEvents(Event event, Executor executor) {
          event.fireAsync(new Foo(), NotificationOptions.ofExecutor(executor));
      }
      

      Attachments

        Activity

          People

            mkouba@redhat.com Martin Kouba
            mkouba@redhat.com Martin Kouba
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: