-
1. Re: Weld CDI context propagation
christopherp Mar 29, 2012 11:47 AM (in response to rabiter)Looks like I ran into the same problem as you Ivan. I found a way to work around the problem by using a database to store a CDI message queue for each user. The CDI messages can be left by asynchronous threads, and then picked up within the user's session context. This glassfish ticket relates to the same problem: http://java.net/jira/browse/GLASSFISH-17152
But note that it's not a bug, it's just undefined behavior.
Hope that helps!
-
2. Re: Weld CDI context propagation
rabiter Mar 30, 2012 10:39 AM (in response to christopherp)Thanks for your replay!
So if I've got it correctly, you use a database as a storage for results of asynchronously executed tasks. And then, each user's SessionScoped (or RequestScoped) bean can pick the result manually from the database. Yep... this is the first solution I've got in my mind. But instead of the database, I use ApplicationScoped bean (in my case it is quite satisfactorily).
-
3. Re: Weld CDI context propagation
christopherp Mar 31, 2012 12:35 PM (in response to rabiter)Yep, either would work fine. ApplicationScoped bean would make it simpler actually. I have to make sure all messages and data trasfer objects are serializable. You wouldn't have to worry about that with an ApplicationScoped bean.
Good luck!