[cdi-dev] What, if any, guarantees are made about invoking asynchronous event observer methods?

Laird Nelson ljnelson at gmail.com
Thu May 11 15:30:17 EDT 2017


I'm using CDI 2.0 and Weld 3.0.0.CR2 in "SE mode".

If I fire an asynchronous event without any special notification options,
my understanding is that the container will arrange for that event to be
delivered to asynchronous observers.

Is (appropriate) asynchronous observer method invocation guaranteed to
happen at some point?  Section 10.2.2 seems to hint that it is:

"Event fired [sic] with the fireAsync() method is [sic] fired
asynchronously. *All the resolved asynchronous observers* (as defined in
Observer resolution) *are called* in one or more different threads."

To me, this says that if I use fireAsync() to fire an event, then if I have
a (resolved) asynchronous observer method for it it will be notified before
the container closes no matter what.

(I believe I am observing a race condition somewhere in here that might
show that Weld's default asynchronous event delivery machinery does not
actually get around to delivering the event I've queued up before the
container closes.  Sometimes the event is received, sometimes it is not.
Obviously if there is no such guarantee this could be permitted behavior.)

Best,
Laird
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/cdi-dev/attachments/20170511/90fcb120/attachment.html 


More information about the cdi-dev mailing list