N
N
nioterzor2019-05-23 10:47:54
symfony
nioterzor, 2019-05-23 10:47:54

Using transactions in services?

The question is theoretical.
There is a service1 whose actions are wrapped in a transaction.
There is a service2 whose actions are wrapped in a transaction.
There is a service3 that should use 1 and 2, and one common transaction is needed.
How do they act in such cases?
In my understanding: transactions are removed from service1 and service2, service1_with_transactions, service2_with_transactions are created, and service1_with_transactions is used instead of service1, similarly for the 2nd.
At the same time, Service3 uses 1 and 2.
I repeat, the question is purely theoretical, I could not immediately come up with real use cases.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
Nikita Dergachov, 2019-05-23
@nioterzor

Flies separately, cutlets separately. Logic needs to be stored in some methods, transactions with a call to logic in another.

I
index0h, 2019-05-23
@index0h

If service 1 and service 2 must be used somewhere else, it makes sense to move their functionality either completely separately, without transactions, or partially into a public method. In the 3rd one transaction.
If you do not do this, working with events after flush, and others like it, becomes at least difficult.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question