kcs / messenger-extra
Additional transports and serializer support for symfony messenger
Fund package maintenance!
alekitto
Installs: 54 560
Dependents: 0
Suggesters: 0
Security: 0
Stars: 19
Watchers: 3
Forks: 10
Open Issues: 1
Requires
- php: ^7.4 || ^8.0
- ext-json: *
- symfony/messenger: ^4.4 || ^5.0 || ^6.0 || ^7.0
- thecodingmachine/safe: ^1.0 || ^2.0
Requires (Dev)
- ext-mongodb: ^1.5
- doctrine/dbal: ^2.10 || ^3.0
- doctrine/orm: ^2.6 || ^3.0
- kcs/serializer: ^2.0 || ^3.0 || ^4.0
- mongodb/mongodb: ^1.4
- phpspec/prophecy-phpunit: ^2.0
- phpunit/phpunit: ^9.0 || ^10.0
- ramsey/uuid: ^4.0
- ramsey/uuid-doctrine: ^2.0
- refugis/doctrine-extra: ^2.2 || ^3.0
- roave/security-advisories: dev-master
- solido/php-coding-standards: dev-master
- symfony/framework-bundle: ^4.2 || ^5.0 || ^6.0 || ^7.0
- symfony/process: ^4.2 || ^5.0 || ^6.0 || ^7.0
- symfony/property-access: ^4.2 || ^5.0 || ^6.0 || ^7.0
- symfony/serializer: ^4.2 || ^5.0 || ^6.0 || ^7.0
Suggests
- ramsey/uuid: Required to use mongodb and dbal transport
- ramsey/uuid-doctrine: Required for DBAL transport
Conflicts
- doctrine/dbal: <3.0
README
This library provides additional transports (and other things) for the symfony messenger component.
Install
composer require kcs/messenger-extra
Transports
Doctrine DBAL
A transport using doctrine DBAL can be used through the DbalTransportFactory
.
Supports delayed, prioritized, expiring (TTL) and unique messages.
The dsn supports the following schemes:
db2
mssql
mysql
mysql2
postgres
postgresql
pgsql
sqlite
sqlite3
Doctrine ORM
An existing ORM connection can be used with doctrine
scheme.
For example doctrine://default/queue
will use the default
doctrine
connection with the queue
table.
The doctrine
scheme will also register a postGenerateSchema
event listener that will create the correct table during a schema update
(or migration if using DoctrineMigrations)
Mongo
Transport using MongoDB PHP client as transport.
Supports delayed, prioritized, expiring (TTL) and unique messages.
Use DSN with mongodb
scheme with /database/collection
path
(database default
and queue
collection are used if not specified).
Mongodb authentication
For authenticated database, with user configured per database, you could
specify authSource
option in DSN query string:
mongodb://user:pass@server:port/database?authSource=database
⚠️ NOTE that if a username is passed in DSN the
authSource
connection option is already added to the mongo uri when passing to the client library. Its value is equal to the database selected (default
if missing).
ℹ️ For information about the supported options in mongo DSN you can check the official documentation page on PHP.net
Null
Useful for testing environments, where no message should be dispatched.
Messages utilities
DelayedMessageInterface
Allows to specify a message delay. Implement this in your message class to delay the delivery of your message.
TTLAwareMessageInterface
Allows the expiration of a message. Implement this interface if you want your message to expire after a given amount of time.
UniqueMessageInterface
Adds a message only once in the queue. If another message with the same uniqueness key is present, the message is discarded.
Compatibility
Symfony bundle
A symfony bundle is included in the code under /lib:
Use MessengerExtraBundle
to fully integrate this library into your symfony application.
Just add this to bundles.php
:
Kcs\MessengerExtra\MessengerExtraBundle::class => ['all' => true],
Available transports and functionalities will be registered automatically.
Amazing things will come shortly.
License & Contribute
This library is released under MIT license.
Feel free to open an issue or a PR on GitHub. If you want to contribute to this project, you're welcome!
A.