Generally
We have some business logic that is causing a bottle neck within a transaction. The business logic queries the database for a set of data (read only), processes it, and returns an object. This must be done many times with varying parameters in a given request. Can we theoretically break off each business logic call into a separate thread?
Specifically
EJB object (part of an http request on a JBoss App Server)
-creates objects that implement Callable (call method calls business logic method)
-using an ExecutorService invoke each callable object
Business Logic
-Makes a query of postgresql database which uses a PreparedStatement
-Using POJOs we build objects from ResultSet objects that come from postgresql
-Do expensive calculations
After all of this we get postgres errors that unnamed portals don't exist even when we limit our threads to one:
ERROR: cursor "<unnamed portal 777>" does not exist
STATEMENT: FETCH ALL IN "<unnamed portal 777>"
I'm not quite sure what is happening to cause the error, but the business logic is being called correctly and it works fine without threading. This leads me to question whether threads can be started and added to a transaction (and if they can how do WE do it?).