My Symfony 6.2 bundle has an handler like the following
use Symfony\Component\Messenger\Attribute\AsMessageHandler;
#[AsMessageHandler]
class MyHandler {
public function __invoke(MyMessage $message): void {
}
}
When I run the bin/command debug:messenger
command I got this output, with the handled part shown twice
MyMessage
handled by MyHandler
handled by MyHandler
Instead, when I use the deprecated method of implementing the MessageHandlerInterface instead of the attribute as follow, the debug command correctly shows only one handled row
use Symfony\Component\Messenger\Handler\MessageHandlerInterface;
class MyHandler implements MessageHandlerInterface {
public function __invoke(MyMessage $message): void {
}
}
I am expecting the attribute version to show one handler like the deprecated version.