[cdi-dev] [JBoss JIRA] (CDI-541) Ordering of async observers (vs sync observers) is not specified

Matej Novotny (JIRA) issues at jboss.org
Wed Nov 4 07:56:00 EST 2015


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

Matej Novotny commented on CDI-541:
-----------------------------------

I can see what you mean now. Previously I thought that it is just about invocation order and that the next observer won't be waiting till the previous (with higher priority) finishes.
While this makes sense I feel it doesn't exactly follow the idea of loose coupling which goes hand in hand with async handling. Furthermore the 'fire and forget' approach might suffer from this as you might need to mind existing observers (that is if you don't intend to leave it default).

Nevertheless, I can definitely see some use cases with the behavior you described. It certainly may come in handy when we want to allow behavior similar to that of sync observers but within a separate thread.

> Ordering of async observers (vs sync observers) is not specified
> ----------------------------------------------------------------
>
>                 Key: CDI-541
>                 URL: https://issues.jboss.org/browse/CDI-541
>             Project: CDI Specification Issues
>          Issue Type: Feature Request
>          Components: Events
>    Affects Versions: 2.0-EDR1
>            Reporter: Tomas Remes
>             Fix For: 2.0-EDR2
>
>
> I think this needs to be specified. E.g. what happens if I fire async event and have more matching sync and async observers? Are all sync observes called first in given order with no regard to async observers priority? 
> For example:
> {{event.fireAsync(new Message());}}
> {code}
> public class First {
>   
>    void observeMessage(@Observes @Priority(2000) Message message){} 
> }
> {code}
> {code}
> public class Second {
>   
>    void observeMessage(@ObservesAsync @Priority(2100) Message message){} 
> }
> {code}
> {code}
> public class Third {
>   
>    void observeMessage(@Observes @Priority(2200) Message message){} 
> }
> {code}
> {code}
> public class Fourth {
>   
>    void observeMessage(@ObservesAsync @Priority(2300) Message message){} 
> }
> {code}
> What will be the order in this case? First, Third, Second, Fourth?



--
This message was sent by Atlassian JIRA
(v6.4.11#64026)


More information about the cdi-dev mailing list