bentools / safe-sync-transport
Symfony Messenger safe synchronous transport.
dev-main
2023-02-01 14:35 UTC
Requires
- php: >=8.0
- symfony/messenger: ^5.4|^6.0
Requires (Dev)
- ext-sqlite3: *
- doctrine/doctrine-bundle: ^2.8
- doctrine/doctrine-migrations-bundle: ^3.2
- doctrine/orm: ^2.14
- pestphp/pest: ^1.22
- phpstan/phpstan: ^1.9
- squizlabs/php_codesniffer: ^3.7
- symfony/console: ^5.4|^6.0
- symfony/doctrine-messenger: ^5.4|^6.0
- symfony/dotenv: ^5.4|^6.0
- symfony/framework-bundle: ^5.4|^6.0
- symfony/runtime: ^5.4|^6.0
- symfony/yaml: ^5.4|^6.0
This package is not auto-updated.
Last update: 2024-11-09 20:51:04 UTC
README
This package offers Symfony Messenger's sync://
transport a different approach:
- Messages are handled synchronously, like in
sync://
transport ✅
But:
- In case of failure (handler produces an exception), messages can be retried
(whereas original
sync://
throws the exception and crashes) 👉 - When max retries have been reached, messages can fall into the
failure_transport
☝️
This way, safe-sync://
can be used as a drop-in replacement of any asynchronous transport, following the same logic
(except messages are now processed synchronously). 👍
Whenever an exception is thrown during message handling, it is caught by the transport, which applies the rules you defined within your messenger.yaml
.
Installation
composer require bentools/safe-sync-transport
Usage
Example:
# config/packages/messenger.yaml framework: messenger: failure_transport: failed transports: sync: dsn: 'safe-sync://' retry_strategy: max_retries: 3 delay: 100 multiplier: 2 failed: dsn: 'doctrine://default' routing: App\DummyMessage: sync
Tests
composer test
License
MIT.