I have some Session EJB that execute sets of fairly long running queries to obtain data (via a DAO to the JDBC). In the EJB client (the graphical user interface) I would like to make it possible for the user to cancel the query (I can limit the query to a Select only; don't have to deal cancelling of updates/inserts thankfully; it's kind of an "oops, nevermind" functionality). Certainly once you invoke a method on an EJB from the client via the corresponding remote interface, assuming the appropriate transaction demarcation in the EJB deployment descriptor, then the corresponding method in the Bean instance (in the server or its container) is going to execute and I can see no standard way to stop the execution of the bean's method within the server from the client (or even from somewhere else in the server). I am thinking that if I put the actual remote method invocations (using the remote interface of the bean) on another thread, and then monitor that thread in the GUI, it should be possible to simply orphan the query
to "sort of" cancel (ignore really). There would seem to some issues around the fact that the method is still technically exeucting within the EJB as pertains to subsequent queries on the same database elements especially subsequent updates/inserts. If any has some ideas on this
please let us know.