Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[DoctrineBridge] fix messenger bus dispatch inside an active transaction#57816

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation

@IndraGunawan
Copy link
Contributor

QA
Branch?5.4
Bug fix?yes
New feature?no
Deprecations?no
IssuesFix #...
LicenseMIT

it was working fine with the below config and command.

# config/packages/messenger.yamlframework:messenger:buses:sync_bus:middleware:                    -validation                    -doctrine_ping_connection                    -doctrine_close_connection                    -doctrine_open_transaction_logger                    -doctrine_transactionrouting:App\Message\SyncJob:sync
<?php// src/Command/TestComand.phpnamespaceApp\Command;useApp\Message\SyncJob;useDoctrine\ORM\EntityManagerInterface;// use ...#[AsCommand(    name:'app:test',    description:'Add a short description for your command',)]class TestCommandextends Command{publicfunction__construct(privatereadonlyEntityManagerInterface$em,privatereadonlyMessageBusInterface$bus,    )    {parent::__construct();    }protectedfunctionexecute(InputInterface$input,OutputInterface$output):int    {$io =newSymfonyStyle($input,$output);$this->bus->dispatch(newSyncJob('someone'));$io->success('You have a new command! Now make it your own! Pass --help to see your options.');return Command::SUCCESS;    }}

An issue occurs if I dispatch the message inside a transaction

$this->em->wrapInTransaction(function ($em) {// another process here$this->bus->dispatch(newSyncJob('someone'));});

an error comes up

ERROR     [app] A handler opened a transaction but did not close it.

This PR aims to fix this issue without changing the existing behaviour

@carsonbotcarsonbot added this to the5.4 milestoneJul 24, 2024
@carsonbotcarsonbot changed the titlefix messenger bus dispatch inside an active transaction[DoctrineBridge] fix messenger bus dispatch inside an active transactionJul 24, 2024
@nicolas-grekasnicolas-grekasforce-pushed thefix-messenger-dispatch-transaction branch from4e9be68 tof164370CompareJuly 26, 2024 12:05
@nicolas-grekas
Copy link
Member

Thank you@IndraGunawan.

IndraGunawan reacted with thumbs up emoji

@nicolas-grekasnicolas-grekas merged commita123a45 intosymfony:5.4Jul 26, 2024
@IndraGunawanIndraGunawan deleted the fix-messenger-dispatch-transaction branchJuly 26, 2024 12:37
This was referencedJul 26, 2024
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Projects

None yet

Milestone

5.4

Development

Successfully merging this pull request may close these issues.

4 participants

@IndraGunawan@nicolas-grekas@xabbuh@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp