jwage / phpamqplib-messenger
Symfony messenger transport for the php-amqplib/php-amqplib library.
Installs: 448
Dependents: 0
Suggesters: 0
Security: 0
Stars: 25
Watchers: 5
Forks: 2
Open Issues: 2
Type:symfony-bundle
Requires
- php: ^8.3
- php-amqplib/php-amqplib: ^3.7
- symfony/framework-bundle: ^5.4 || ^6.4 || ^7.0
- symfony/messenger: ^5.4 ||^6.3 || ^7.0
Requires (Dev)
- doctrine/coding-standard: ^13.0
- phpunit/phpunit: ^12.1
- psalm/plugin-phpunit: ^0.19.5
- psalm/plugin-symfony: ^5.2
- symfony/phpunit-bridge: ^7.2
- symfony/uid: ^7.2
- vimeo/psalm: ^6
- dev-main
- 0.7.0
- 0.6.4
- 0.6.3
- 0.6.2
- 0.6.1
- 0.6.0
- 0.5.5
- 0.5.4
- 0.5.3
- 0.5.2
- 0.5.1
- 0.5.0
- 0.4.1
- 0.4.0
- 0.3.0
- 0.2.1
- 0.2.0
- 0.1.0
- dev-feature/deduplication-plugin-middleware
- dev-feature/batch-dispatch-improvements
- dev-fix/dsn-parser-auto-setup
- dev-fix/message-attributes
- dev-fix/consumer-retries
- dev-fix/close-consumer
- dev-fix/auto-setup
- dev-fix-54-psalm
This package is auto-updated.
Last update: 2025-04-24 15:47:22 UTC
README
This bundle adds support for php-amqplib/php-amqplib
to Symfony Messenger, providing an alternative way to connect to RabbitMQ using a pure PHP library instead of the php-amqp C extension.
Installation
composer require jwage/phpamqplib-messenger
Make sure the bundled is enabled in config/bundles.php
:
return [ // ... Jwage\PhpAmqpLibMessengerBundle\PhpAmqpLibMessengerBundle::class => ['all' => true], ];
The minimum configuration required is the transports name and the DSN.
# config/packages/messenger.yaml framework: messenger: transports: orders: dsn: 'phpamqplib://guest:guest@localhost:5672/myvhost/orders'
The configuration above will create an exchange named orders
and bind a queue named orders
to it within the vhost myvhost
.
Roadmap
The objective and future roadmap for this bundle is to achieve version 1.0 as a third-party Symfony bundle first, and then subsequently integrate it into the Symfony core for Symfony 7.4 LTS, as symfony/phpamqplib-messenger
, providing an alternative to symfony/amqp-messenger
.
Documentation
For detailed documentation, including advanced configuration options, features, and usage examples, please see the documentation.
Why use this bundle?
There are several reasons why you might prefer to use the php-amqplib/php-amqplib
library over the php-amqp
C extension for connecting to RabbitMQ in Symfony Messenger:
-
Asynchronous Consumers: The
php-amqplib
library properly implements asynchronous consumers, which allows for more efficient message handling. This is particularly useful for advanced use cases where you need to handle a large number of messages concurrently. -
Active Maintenance: Both
php-amqplib
andphp-amqp
are actively maintained by VMware. However,php-amqplib
is often preferred for its flexibility and ease of use in PHP applications. -
PHP Version Compatibility: Using
php-amqplib
makes upgrading PHP versions easier, as it does not rely on a C extension that may have compatibility issues with newer PHP versions. -
Efficient Message Streaming: The
php-amqplib
library allows for proper streaming of messages from the server, avoiding the inefficiencies of constant polling withget()
. This means that you can maintain an open stream connection and control how long to wait for messages, which is not possible with thephp-amqp
extension. -
Safe Worker Shutdown: With
php-amqplib
, you can safely stop your workers usingpcntl
signals, ensuring that your handlers do not get shut down mid-message handling. This is a significant advantage over thephp-amqp
extension, where theconsume()
method does not work as expected, leading to potential issues with worker shutdown.
In summary, php-amqplib
provides a more robust and flexible solution for connecting to RabbitMQ in Symfony Messenger, making it the preferred choice for many developers.
Message Reliability
This bundle prioritizes message reliability over raw performance. By default, confirms are enabled to ensure that messages are acknowledged by the server. In the event of a connection exception, publishes are retried if there is uncertainty about whether a message was received by the server. This approach ensures that messages are not lost, but it also means that a message could potentially be published twice. Therefore, it is crucial to ensure that your message handlers are 100% idempotent to handle such scenarios gracefully.
Acknowledgements
We would like to express our sincere gratitude to @videlalvaro, the author of the php-amqplib library, for his invaluable contributions to the development of this project. We also acknowledge Microsoft for supporting his efforts, as he utilized company time to help make this Symfony bundle a robust and reliable solution for connecting to RabbitMQ in Symfony applications.
License
This bundle is licensed under the MIT License. See the LICENSE file for details.