handcraftedinthealps / redis-transport-bundle
A symfony messenger transport implementation for redis streams.
Installs: 15 678
Dependents: 0
Suggesters: 0
Security: 0
Stars: 6
Watchers: 3
Forks: 5
Open Issues: 1
Type:symfony-bundle
Requires
- php: ^7.3 || ^8.0
- ext-redis: ^4.2 || ^5.0 || ^6.0
- symfony/config: ^3.4 || ^4.0 || ^5.4 || ^6.0
- symfony/dependency-injection: ^3.4 || ^4.0 || ^5.4 || ^6.0
- symfony/messenger: ^4.3 || ^5.4 || ^6.0
- symfony/property-access: ^3.4 || ^4.0 || ^5.4 || ^6.0
- symfony/serializer: ^3.4 || ^4.0 || ^5.4 || ^6.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.0 || ^3.9
- phpspec/prophecy-phpunit: ^2.0
- phpstan/phpstan: ^1.8
- phpstan/phpstan-symfony: ^1.2
- phpunit/phpunit: ^9.5
- symfony/console: ^3.4 || ^4.0 || ^5.4 || ^6.0
- symfony/error-handler: ^3.4 || ^4.0 || ^5.4 || ^6.0
- symfony/framework-bundle: ^3.4 || ^4.0 || ^5.4 || ^6.0
- symfony/redis-messenger: ^5.4 || ^6.0
- symfony/yaml: ^3.4 || ^4.0 || ^5.4 || ^6.0
Suggests
- symfony/redis-messenger: Required if version of symfony/messenger is >= 5.1
README
A symfony messenger transport implementation for redis streams.
NOTE: Most of the logic has moved to the Core Symfony Messenger component in 4.3. So this bundle is not longer a requirement to use messenger with redis streams. You can now use the
redis://
instead ofredis-stream://
and remove this bundle from your requirements.
Requirements
- PHP:
^7.1
- Redis Extension:
^4.2
- Redis Extension:
- Redis Server:
^5.0
Symfony compatibility
When upgrading to symfony 4.3 you should replace this bundle
with the symfony redis://
transport and remove the bundle
from your requirements.
Installation
You need composer to install this bundle to your symfony application.
composer require handcraftedinthealps/redis-transport-bundle
Configuration
Symfony
When using the symfony/framework-bundle you can configure the following:
# config/packages/framework.yaml framework: messenger: routing: 'HandcraftedInTheAlps\Bundle\RedisTransportBundle\Message\DomainEventMessage': senders: ['redis_stream'] transports: redis_stream: 'redis-stream://127.0.0.1:6379/my_stream/my_group/my_consumer'
You can then send a DomainEventMessage or your custom Message over the redis stream:
use HandcraftedInTheAlps\Bundle\RedisTransportBundle\Message\DomainEventMessage; $this->messageBus->dispatch( new DomainEventMessage( 'mountain.modified', // the custom event action 'mountain', // the model which has been changed '1', // the model id or uuid [ // the model payload 'id' => '1', 'name' => 'Piz Buin', 'height' => 3312, ] ) );
And you can consume the messages with:
bin/console messenger:consume-messages redis_stream
Have also a look at the messenger component documentation and messenger usage documentation.
Commands
Messages in streams won't be removed by default. Therefor this bundle provides a command:
bin/console redis-transport:trim <redis-dsn> --maxlen 1000