2017 © Pedro Peláez
 

magento2-module amqp

Use the power of RabbitMQ in your e-commerce running with Magento 2.

image

monsieurbiz/amqp

Use the power of RabbitMQ in your e-commerce running with Magento 2.

  • Sunday, December 17, 2017
  • by jacquesbh
  • Repository
  • 3 Watchers
  • 2 Stars
  • 0 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

MonsieurBiz AMQP

Use the power of RabbitMQ in your e-commerce running with Magento 2., (*1)

Installation

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)

Create an exchange

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

Consume a queue

You have to create a consumer/worker., (*7)

Take a look at Console/Command/SampleCommand.php, it is a basic consumer., (*8)

Send a message in an exchange

Considering that $amqp is an instance of \MonsieurBiz\Amqp\Helper\Amqp., (*9)

Direct message

$amqp->sendMessage(
    'consume-me',
    ['my message content']
);

Delayed message

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
        ]),
    ]
);

RPC

Considering that $rpc is an instance of \MonsieurBiz\Amqp\Helper\Rpc., (*11)

Direct request

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"]

Batch messages

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)

LICENSE

(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)

The Versions

17/12 2017

dev-master

9999999-dev

Use the power of RabbitMQ in your e-commerce running with Magento 2.

  Sources   Download

MIT

The Requires