I have a Stateless EJB method(ejbMethod1) that needs to call a web service operation(wsOper1), if this call fails It needs to call another web service operation(wsOper2).
My problem is: I don't need the returning of wsOper2 to return from ejbMethod1! I want to delegate this work to another piece of my application and return immediately.
Option1:: My first approach to this problem was to use a global LinkedBlockingQueue for storing an Object representing the wsOper2 I needed to do, and have N threads retrieving elements from this queue and executing the call.
Option2:: Create a Runnable and delegate to some global thread pool. There is one that I can use?
Or is another option that I'm not contemplating?
... PS: Im using Glassfish 4.1 & JRE8 and I'm new to the Java EE world :P
UPDATED:
I used a ManagedExecutorService to execute wsOper2 asynchronously as a Runnable.
@Resource
private ManagedExecutorService executor;
Thanks Ryan :)