Download the PHP package happyr/mq2php-bundle without Composer
On this page you can find all versions of the php package happyr/mq2php-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download happyr/mq2php-bundle
More information about happyr/mq2php-bundle
Files in happyr/mq2php-bundle
Package mq2php-bundle
Short Description Automatically consume messages from a message queue without using a cron. Works great with SimpleBus
License MIT
Informations about the package mq2php-bundle
Mq2phpBundle for real asynchronous messages
This bundle is a bridge between SimpleBus and mq2php. It could be used together with the SimpleBusAsynchronousBundle to make the asynchronous messages independent of a cron job to consume the messages. Instead we utilize the power of PHP-FPM to schedule workload and resources.
Consuming messages from the queue
We do not want to run a cron command to consume messages from the queue because of two reasons. It takes a lot of computer resources to create a new thread and if we only do one task there will be a lot of overhead. The second reason is that we want to be able to do resource scheduling. With a cronjob we say "Consume this message at the next minute no matter your current load". Instead we would like to do something like: "Consume this message as soon as possible".
The solution to these problems is nothing new. It is actually exact the problems PHP-FPM is solving. We just need a way to pull messages from the message queue and give those to PHP-FPM.
This is where mq2php comes in. It is a Java application that will run in the background. Java is preferred because it is build to run for ever. (Compared with PHP that should never be running for more than 30 seconds.)
Installation
Fetch mq2php.jar version 0.5.0 or above and start the application with:
You should consider using the init script when you using it on the production server.
Install and enable this bundle
Configuration
HTTP executor
If you are not using fastcgi (eg PHP-FPM) you may use HTTP.
Shell executor
When debugging you may want to use the shell executor. This will require more CPU resources by mq2php since starting a new process to for each message is heavy.
Verify the message
If you want to be sure that your message is valid and from your application you should define a secret key. This key is used to hash the message and then verify the hash on the receiving end. If you are using multiple applications you should make sure they all have the same secret key.
Reduce the number of messages
In the SimpleBus documentation you may find that all events will be handled synchronous then asynchronous. That means that for every event your application dispatches there will be an async message. If you want to reduce the number of messages you may configure the SimpleBus AsyncBundle to only handle those events that are marked as asynchronous.
All versions of mq2php-bundle with dependencies
psr/log Version ~1.0
simple-bus/asynchronous-bundle Version ^3.0
symfony/dependency-injection Version ^3.4 || ^4.0
symfony/http-kernel Version ^3.4 || ^4.0
symfony/framework-bundle Version ^3.4 || ^4.0
symfony/console Version ^3.4 || ^4.0
symfony/event-dispatcher Version ^3.4 || ^4.0