A Simple Bundle to version your Symfony Messenger messages.
- Versionning of a message
- Requeuing consumers that has different version with the concerned message
- PHP >= 7.4
- symfony/messenger
composer require jhyangxyz/messenger-version-control
Configure this Middleware to your MessageBus
<?php
return [
...,
Jhyangxyz\MessengerVersionControl\JhyangxyzMessengerVersionControlBundle::class => ['all' => true],
];
framework:
messenger:
buses:
message.bus.commands:
middleware:
- jhyangxyz.messenger_version_control.middleware.version_checker_middleware
<?php
namespace App\Message;
use Jhyangxyz\MessengerVersionControl\Message\AbstractVersionedMessage;
final class FooMessage extends AbstractVersionedMessage
{
public function __construct()
{
$this->setVersion();
}
public function getBuildVersion(): int
{
return 1;
}
}
<?php
namespace App\MessageHandler;
use Jhyangxyz\MessengerVersionControl\MessageHandler\AbstractVersionedMessageHandler;
final class FooMessageHandler extends AbstractVersionedMessageHandler
{
public function __invoke(FooMessage $message)
{
$this->checkVersion($message);
//Handle message
...
}
}