dev-master
9999999-devUse the power of RabbitMQ in your e-commerce running with Magento 2.
MIT
The Requires
- php ~7.0.0
- magento/framework 100.0.*|100.1.*
- php-amqplib/php-amqplib ^2.6
Use the power of RabbitMQ in your e-commerce running with Magento 2.
Use the power of RabbitMQ in your e-commerce running with Magento 2., (*1)
With composer: composer require monsieurbiz/amqp
., (*2)
If you want to use delayed messages then you'll have to install the [Delayed Message Plugin][https://github.com/rabbitmq/rabbitmq-delayed-message-exchange] on your RabbitMQ instance., (*3)
magento monsieurbiz:amqp:exchange:create consume-me
With consume-me
as exchange name., (*4)
You can also use a delayed exchange:, (*5)
magento monsieurbiz:amqp:exchange:create --delayed consume-me
You can create multiple exchange at once:, (*6)
magento monsieurbiz:amqp:exchange:create first-exchange-name second-exchange-name
You have to create a consumer/worker., (*7)
Take a look at Console/Command/SampleCommand.php
, it is a basic consumer., (*8)
Considering that $amqp
is an instance of \MonsieurBiz\Amqp\Helper\Amqp
., (*9)
$amqp->sendMessage( 'consume-me', ['my message content'] );
You need to install the Delayed Message Plugin on your RabbitMQ instance., (*10)
$amqp->sendMessage( 'consume-me', ['my message content'], [ 'application_headers' => new AMQPTable([ 'x-delay' => 5000 // 5 seconds of delay ]), ] );
Considering that $rpc
is an instance of \MonsieurBiz\Amqp\Helper\Rpc
., (*11)
To send a request to the broker and get a response right away:, (*12)
$response = $rpc->directRequest( 'consume-me', ['my message content'] ); echo $response; // ["my message content"]
Before sending a batch, you should be aware on how RPC works., (*13)
Don't forget to keep the correlation identifier of every request you make., (*14)
$c1 = $rpc->request('consume-me', ['my first message']); $c2 = $rpc->request('consume-me', ['my second message']); $responses = $rpc->getResponses(); var_dump($responses[$c1]); // string(20) "["my first message"]" var_dump($responses[$c2]); // string(21) "["my second message"]"
More you have consumers running faster you'll get the responses., (*15)
(c) Monsieur Biz opensource@monsieurbiz.com, (*16)
For the full copyright and license information, please view the LICENSE file that was distributed with this source code., (*17)
Use the power of RabbitMQ in your e-commerce running with Magento 2.
MIT