<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
webignition / symfony-messenger-delay-middleware example snippets
declare(strict_types=1);
namespace App\MessageDispatcher;
use App\Message\FooMessage;
use App\Message\BarMessage;
use Symfony\Component\Messenger\MessageBusInterface;
final readonly class ExampleMessageDispatcher
{
public function __construct(
private MessageBusInterface $messageBus,
) {}
public function dispatchFooMessage(): void
{
// Delayed by one second as per the previous example configuration.
$this->messageBus->dispatch(new FooMessage());
}
public function dispatchBarMessage(): void
{
// Delayed by thirty seconds as per the previous example configuration.
$this->messageBus->dispatch(new BarMessage());
}
}
declare(strict_types=1);
namespace App\MessageDispatcher;
use App\Message\FooMessage;
use App\Message\BarMessage;
use Symfony\Component\Messenger\MessageBusInterface;
use webignition\SymfonyMessengerDelayMiddleware\NonDelayedStamp;
final readonly class ExampleMessageDispatcher
{
public function __construct(
private MessageBusInterface $messageBus,
) {}
public function dispatchFooMessageWithoutDelay(): void
{
// FooMessage is dispatched immediately despite being configured to delay.
$this->messageBus->dispatch(new FooMessage(), [new NonDelayedStamp()]);
}
public function dispatchBarMessageWithoutDelay(): void
{
// BarMessage is dispatched immediately despite being configured to delay.
$this->messageBus->dispatch(new BarMessage(), [new NonDelayedStamp()]);
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.