How to synchronize the request for same session?

26 views
Skip to first unread message

Tushar Patel

unread,
Oct 22, 2014, 2:21:16 AM10/22/14
to induction...@googlegroups.com
We have all our business logic written as Stateful EJB component. This doesn't allow concurrent access. So If I have concurrent AJAX call through UI then it throws the Runtime Exception. This exception causes EJB to be removed which leaves the stale reference in session.

We want to queue (synchronized) the request if it is for the same session to avoid the issue. So my question is What is the best way to synchronize the request of same session? Should I just make HttpDispatcher.dispatchRequest() method synchronized?

Thanks.

Adinath Raveendra Raj

unread,
Nov 3, 2014, 1:41:51 AM11/3/14
to induction...@googlegroups.com
Tushar,

I would not recommend making the entire method synchronized, since this would *severely* restrict containers ability to process web requests. Consider using a synchronization block that is specific to the session or better yet to the specific application module instance with the issue. Also, as far as I know concurrently accessing an EJB does not cause it to die, what is likely happening is a nested EJB call, and the nested call is throwing a concurrent access exception (a runtime exception) which if not handled by the caller will call the calling EJB to die.

Hope this helps.

Adi

--
You received this message because you are subscribed to the Google Groups "Induction Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to induction-frame...@googlegroups.com.
To post to this group, send email to induction...@googlegroups.com.
Visit this group at http://groups.google.com/group/induction-framework.
For more options, visit https://groups.google.com/d/optout.


Reply all
Reply to author
Forward
0 new messages