Quantcast
Channel: Active questions tagged symfony4 - Stack Overflow
Viewing all articles
Browse latest Browse all 3918

Symfony MessageHandler count how many times a message has been dispatched

$
0
0

I'm using Symfony Messenger and I want to keep dispatching a message in the handler until it has been dispatched a number of times.

How can I keep track of that?

This is the code of my handler class so far:

class RetryTestHandler implements MessageHandlerInterface{    /**    * @var EntityManagerInterface    */    private $entityManager;    /**     * @var MessageBusInterface     */    private $bus;    public function __construct(MessageBusInterface $bus, EntityManagerInterface $entityManager)    {        $this->entityManager = $entityManager;        $this->bus = $bus;    }    public function __invoke(RetryTest $message)    {        // TODO: Keep dispatching message until it has been dispatched 10 times?        $this->bus->dispatch(new RetryTest("This is a test!"), [            new DelayStamp(5000)        ]);    }}

Viewing all articles
Browse latest Browse all 3918

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>