Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WithoutDbalTransaction attribute: possibility dot not wrap specific async endpoint or command handler in transaction #425

Open
lifinsky opened this issue Dec 28, 2024 · 4 comments

Comments

@lifinsky
Copy link
Contributor

Description
Command handlers or asynchronous endpoints are used only to send commands to other services or simply do not store anything in the database and obviously would like to avoid running a transaction on a specific endpoint.

Example

#[Asynchronous("db")]
#[EventHandler(endpointId: "notify")]
#[WithoutDbalTransaction]
public function notify(OrderWasPlaced $event) : void
{
    // distributed bus call
}
@dgafka
Copy link
Member

dgafka commented Dec 28, 2024

That would not be feasible to do it on the Handler level, because transaction is already started at that point.
However you can already set up a Message Consumer without transactions:

    DbalConfiguration::createWithDefaults()
        ->withoutTransactionOnAsynchronousEndpoints(["db"]

@lifinsky
Copy link
Contributor Author

lifinsky commented Dec 28, 2024

@dgafka I know, but unfortunately at the service level there are usually three consumers (distributed, db and async internal) and for outbox (db + async internal) not all db channels can be without a transaction

@lifinsky
Copy link
Contributor Author

Sometimes, instead of selectively adding a transaction block using the DbalTransaction attribute, it is easier to selectively disable it.

@lifinsky
Copy link
Contributor Author

For example, we use db channel for ditributed bus call, where transaction is not needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants