[cdi-dev] [JBoss JIRA] (CDI-729) Async event not CompletionStage friendly

Romain Manni-Bucau (JIRA) issues at jboss.org
Mon Jun 18 09:11:01 EDT 2018

    [ https://issues.jboss.org/browse/CDI-729?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13592701#comment-13592701 ] 

Romain Manni-Bucau commented on CDI-729:

I'm using events because I don't know the impl I will use (it is a library which is integrated with some 3rd party backend). The event is very handy on both side since it doesn't couple strongly both maintainers. The only blocking point is to have what CDI provides in synchronous mode: return when done. For completionstage it is providing a way to register another stage in the event chain.

I can't put the chaining in the caller (because I don't know it)
I can't throw an exception in the observer because the processing is done through a completionstage in another thread so it is missed and likely happen after the caller already returned anyway (timing issue). This is also why fire() (not async) doesn't work.

I'm not sure I got your solution but sounds like registering a task to delay the completion of the returned stage is not a big deal (clearly not in impl side) and would help to be reactive in apps.

> Async event not CompletionStage friendly
> ----------------------------------------
>                 Key: CDI-729
>                 URL: https://issues.jboss.org/browse/CDI-729
>             Project: CDI Specification Issues
>          Issue Type: Feature Request
>            Reporter: Romain Manni-Bucau
> The goal of this ticket is to enable user to get injected the completion future instead of the raw event and return another completion stage (generic type ignored) to enable the "chain" to be synched.
> Here is a sample:
> 1. fireAsync(persistEvent)
> 2. observer implementation does: return future.thenCompose(db::doAsyncPersist)
> 3. when the user gets back the result of the fireAsync the doAsyncPersist is completed.

This message was sent by Atlassian JIRA

More information about the cdi-dev mailing list