Hello,
Is it even possible to use dfc transaction in multiple threads?
I'm starting transaction in one thread. Then in another thread I'm trying to lock object within defined time period (5 seconds). For this I'm using IDfPersistenObject.lockEx(false).
If it's not possible to lock it (maybe another batch is working with it) I just want to rollback current operation.
When I create session in one thread and start transaction, this transaction is not started in second thread.
in DFC api I can see
- IDfSessionManager.beginTransaction()
- Starts a new "managed" transaction (repository transaction). There are three scenarios:
beginTransaction
is called but there is no repository session yet. In this case a flag is set and when the first session is retrieved (using getSession
) the transaction is started.- In case of multiple threads, transaction handling operates on the current thread. This means the session manager will manage transactions for each thread separately. For example if there is an existing DFC session for one thread, a new session is created for the second thread automatically.
- Another special case to be handled is where a first thread gets a session. Then a second thread also gets a session and starts a transaction. In this case it is not possible to start a transaction for the first thread since in may be in the middle of doing something that does not require a transaction.
Remember, that repository transactions depend on the underlying RDBMS transactions.
Only sessions obtain after the call to beginTransaction
method will be able to participate in the transaction. Session objects obtain before beginTransaction
will not be able to participate in the transaction.
Nested transactions are not supported. You cannot begin a new transaction using either the beginTransaction
or IDfSession.beginTrans
methods once either type of transaction is already started.
so is there way to share transaction between threads?
Thanks