[JBoss JIRA] (CDI-31) Asynchronous events
by Jonathan Fisher (JIRA)
[ https://issues.jboss.org/browse/CDI-31?page=com.atlassian.jira.plugin.sys... ]
Jonathan Fisher commented on CDI-31:
------------------------------------
I've used the @Asynchronous workaround, which is why I began advocating this position. While it works ok for small numbers of EJBs, but EJBs aren't nearly as memory efficient as the pojo based model of CDI.
I'm advocating this position because we all know how long Java specs live for, and asynchronous dispatching and easy multithreading are going to be huge measurements of languages in the very near future. While CPU speeds will still increase going into the future, we're going to see a greater increase in core count and thread count per core.
> Asynchronous events
> -------------------
>
> Key: CDI-31
> URL: https://issues.jboss.org/browse/CDI-31
> Project: CDI Specification Issues
> Issue Type: Feature Request
> Components: Events
> Affects Versions: 1.0
> Reporter: Nicklas Karlsson
> Fix For: TBD
>
>
> Consider including asynchronous events as their were specified in one of the previous drafts.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.jboss.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
12 years, 8 months
[JBoss JIRA] (CDI-31) Asynchronous events
by Jonathan Fisher (JIRA)
[ https://issues.jboss.org/browse/CDI-31?page=com.atlassian.jira.plugin.sys... ]
Jonathan Fisher edited comment on CDI-31 at 4/12/12 11:57 AM:
--------------------------------------------------------------
Also on the note of immutability, don't box the developer in. It would be better to simply published best practices stating that events should almost always be immutable, but there may be a use case you haven't thought of.
was (Author: exabrial):
Also on the note of immutability, don't box the developer in. it would be better to simply published best practices stating that state enters should almost always be immutable, but there may be a use caw you haven't thought of.
> Asynchronous events
> -------------------
>
> Key: CDI-31
> URL: https://issues.jboss.org/browse/CDI-31
> Project: CDI Specification Issues
> Issue Type: Feature Request
> Components: Events
> Affects Versions: 1.0
> Reporter: Nicklas Karlsson
> Fix For: TBD
>
>
> Consider including asynchronous events as their were specified in one of the previous drafts.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.jboss.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
12 years, 8 months
[JBoss JIRA] (CDI-31) Asynchronous events
by Stuart Douglas (JIRA)
[ https://issues.jboss.org/browse/CDI-31?page=com.atlassian.jira.plugin.sys... ]
Stuart Douglas commented on CDI-31:
-----------------------------------
I think that this could be as simple as Event.fireAsync() and BeanManager.fireAsyncEvent().
The events observers would still be notified synchronously in respect to each other (i.e. in the same thread), but fireAsync would return immediately. The async event would have its own request context, in much the same way as an async EJB invocation.
The main reason why I am against specifying the threading type on the observer is that it means that if a 3rd party adds an async observer to an event it opens you up to some very nasty thread safety bugs if you are not using immutable events.
> Asynchronous events
> -------------------
>
> Key: CDI-31
> URL: https://issues.jboss.org/browse/CDI-31
> Project: CDI Specification Issues
> Issue Type: Feature Request
> Components: Events
> Affects Versions: 1.0
> Reporter: Nicklas Karlsson
> Fix For: TBD
>
>
> Consider including asynchronous events as their were specified in one of the previous drafts.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.jboss.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
12 years, 8 months
[JBoss JIRA] (CDI-31) Asynchronous events
by Mark Struberg (JIRA)
[ https://issues.jboss.org/browse/CDI-31?page=com.atlassian.jira.plugin.sys... ]
Mark Struberg commented on CDI-31:
----------------------------------
Well, from a design perspective the current event is more like a method invocation with targets which are unknown to the caller. Thus they are atm perfectly fine to collect data from the @Observer methods.
That might also be possible if using asynchronous events. But in that case the event object would need to support multiple concurrency (which is not defined atm). Thus we cannot simply enable this in a backward compatible fashion. We would need to add a new annotation or new member value in @Observes or with the Event<T> source / EntityManager#fire(), e.g.
public enum ObserverType {
SYNCHRONOUS,
ASYNC_WAIT,
ASYNC_NOWAIT
}
Please be aware that both async methods have implications to the environment. We would e.g. need to limit the max number of Event-threads to spawn, otherwise we will quickly kill our Server.
But don't expect wonders! I'd say that in 99% of the cases the overhead to start and manage those threads is bigger than the costs of invoking all events synchronously...
ASYNC_NOWAIT (similar to @Asynchronous EJBs) is btw pretty dangerous as it is NOT relyable, must not share Session and Request Contexts, etc!
> Asynchronous events
> -------------------
>
> Key: CDI-31
> URL: https://issues.jboss.org/browse/CDI-31
> Project: CDI Specification Issues
> Issue Type: Feature Request
> Components: Events
> Affects Versions: 1.0
> Reporter: Nicklas Karlsson
> Fix For: TBD
>
>
> Consider including asynchronous events as their were specified in one of the previous drafts.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.jboss.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
12 years, 8 months