Hi!
Since you want to run these things in an application server, I would be less inclined to use the solution which involves creating threads and a thread pool.
I would want to invoke the payment gateway asynchronously, as outlined in my previous posting.
There are a few ways that you can do that:
1.
EJB 3.1 supports asynchronous calls.
When an asynchronous method is invoked on an EJB, the caller receives a Future object. This object can be polled for a result and, if 30 seconds have passed with no result having arrived, the web service operation "times out".
Reference:
http://java.sun.com/developer/technicalArticles/JavaEE/JavaEE6Overview_Part3.html
2. Messaging
More involved than the above alternative, but also more independent of the application server in which the application is to be deployed.
The web service sends (asynchronous) messages to a queue. These messages are received and processed by the payments gateway. Message correlation is used and the payments gateway sends responses to a response queue.
Reference: Java Message Service 2nd Edition, chapter 4.
There are surely other alternatives, but these are the simpler ones that I can think of.
Best wishes!