Returning status from long-running session bean method

417 Views Asked by At

I am using JSF 2.0 with RichFaces 4.2.2 running on Glassfish 3.1.2. I have created local stateless session beans with a long-running method that will be called by the JSF managed bean.

I would like to be able to push status information from the session bean back to the managed bean so that I can use something like RichFaces a4j:push to get the status to the browser. I believe this would require that the call to the session bean method would be asynchronous. Are there patterns for pushing information from session beans back to the front end as the session bean is processing the method call?

1

There are 1 best solutions below

0
On

Stateless session beans (SLSB) are not supposed to hold any state (read: instance variables which are altered by the methods) because they are shared between all clients applicationwide. So they are useless to you if you need a session bean with some state which you can update during the process and which the client can request anytime. You need a stateful session bean (SFSB) instead. If you inject the SFSB in a session scoped JSF managed bean, then you'll be able to request the proper status from it and push it to the client throughout the HTTP session.

To understand the difference between SLSB and SFSB better, you may find this answer helpful: JSF request scoped bean keeps recreating new Stateful session beans on every request?