Can a transaction have many threads?

Generally

We have business logic calling the neck of a bottle inside a transaction. Business logic queries the database for a data set (read-only), processes it, and returns an object. This needs to be done many times with various parameters in this query. Can we theoretically catch every call of business logic in 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 that, we get postgres errors that unnamed portals do not exist, even when we restrict 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 gets called correctly and it works fine without streaming. This makes me wonder if it is possible to start threads and add to a transaction (and can they do this?).

+3
3

EJB ( - , ). , JMS , WorkManager concurrency EJB.

+3

JDBC , , " ", , , , , .

, ? , , , .

0

, , , .

, Callable, -, EJB . :

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

Callable Object
-lookup another EJB instance of the class we are already in to get a transaction going
-call that instance business logic

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

, , , , .

0

Source: https://habr.com/ru/post/1724772/


All Articles