Description
Symfony version(s) affected
5.4.2
Description
I call messenger:consume
command from controller, but when in messenger config I add setting reset_on_message: true
exception is thrown by Stopwatch component at the end of script (when its time runs out) in dev environment when 1 message was processed.
Message itself is handled correctly and messenger is looking for other messages after message is handled.
Uncaught PHP Exception LogicException: "Event "__section__" is not started." at ...\vendor\symfony\stopwatch\Section.php line 143
When no message is processed script runs without exception.
When setting reset_on_message: true
is removed from config script runs without exception.
In profiler I see one orphaned event, but don't know if it is related:
How to reproduce
I use doctrine as transport (not tested other type of transports)
MESSENGER_TRANSPORT_DSN=doctrine://default
Set reset_on_message to true:
framework:
messenger:
reset_on_message: true
# Uncomment this (and the failed transport below) to send failed messages to this transport for later handling.
failure_transport: failed
transports:
# https://symfony.com/doc/current/messenger.html#transport-configuration
create_lead:
dsn: '%env(MESSENGER_TRANSPORT_DSN)%?queue_name=create_lead'
retry_strategy:
max_retries: 2
delay: 300000 #5 minutes
multiplier: 3
routing:
# Route your messages to the transports
# 'App\Message\YourMessage': async
'App\Message\CreateLead': create_lead
Dispatch 1 (any) message e.g.:
$messageBus->dispatch(new CreateLead());
Message handler can be empty:
class CreateLeadHandler implements MessageHandlerInterface
{
/**
* @param CreateLead $message
*/
public function __invoke(CreateLead $message)
{
}
}
Controller:
/**
* @Route("/process", name="process")
* @param KernelInterface $kernel
* @throws Exception
*/
public function process(KernelInterface $kernel)
{
$application = new Application($kernel);
$application->setAutoExit(false);
$arguments = [
'receivers' => ['create_lead',],
'--time-limit' => 10,
];
// You can use NullOutput() if you don't need the output
$input = new ArrayInput(array_merge(['command' => 'messenger:consume'], $arguments));
$output = new NullOutput();
$application->run($input, $output);
return new Response();
}
Call /process
from browser.
Possible Solution
No response
Additional Context
No response