Magento 2 Message Queue Open Source Module

Overview

Magento 2 Message Queue Module

Lightweight implementation of message queue for Magento 2 Community Edition.

Build Status Coverage Status Latest Stable Version Latest Unstable Version Total Downloads License

System requirements

This extension supports the following versions of Magento:

  • Community Edition (CE) versions 2.1.x
  • Community Edition (CE) versions 2.2.x
  • Community Edition (CE) versions 2.3.x

Installation

  1. Require the module via Composer
$ composer require renatocason/magento2-module-mq
  1. Enable the module
$ bin/magento module:enable Rcason_Mq
$ bin/magento setup:upgrade
  1. Install a message queue backend extension of your choice (see Message queue backends section)
  2. Configure your queue(s) and implement your consumer(s) (see Implementation section)
  3. Check the correct configuration of your queue(s)
$ bin/magento ce_mq:queues:list
  1. Run your consumer(s)
$ bin/magento ce_mq:consumers:start product.updates

Message queue backends

This module does not include any message queue backend implementation. You will have to chose and install one of the following modules (or implement your own) in order to get your message queues working:

  • MqMysql - Stores messages in the database
  • MqAmqp - Integrates any AMQP queue manager (i.e. RabbitMQ)
  • Amazon SQS - Integrates Amazon SQS as a queue manager (work in progress)

Implementation

A simple example can be found here.

  1. Configure queue(s) in your module's etc/m2_mq.xml file
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Rcason_Mq:etc/ce_mq.xsd">
    <ceQueue name="product.updates" broker="mysql"
        messageSchema="int"
        consumerInterface="Rcason\MqExample\Model\ExampleConsumer"/>
</config>
  1. Require the publisher in the classes you need it
/**
 * @param \Rcason\Mq\Api\PublisherInterface $publisher
 */
public function __construct(
    \Rcason\Mq\Api\PublisherInterface $publisher
) {
    $this->publisher = $publisher;
}
  1. Use it to queue messages
$this->publisher->publish('product.updates', $productId);
  1. Implement your consumer(s)
class ExampleConsumer implements \Rcason\Mq\Api\ConsumerInterface
{
    /**
     * {@inheritdoc}
     */
    public function process($productId)
    {
        // Your code here
    }
}

Authors, contributors and maintainers

Author:

Contributions:

License

Licensed under the Open Software License version 3.0

Comments
  • Feature Request: Support for failed jobs and jobs priority

    Feature Request: Support for failed jobs and jobs priority

    Hi @renatocason and @grafikchaos ,

    I started to use your module with superviosr process manager to run the queues all the time and it works like a charm. I would like to suggest two features whcih can increase this module capabilities more.

    1. Failed Jobs. This can be a useful feature. Once a job throws an exception, the job information and the exception can be stored in a table like ce_failed_queue_message . Also, failed jobs can be added to queue again.

    2. Jobs Prirotiy: Some time we have high priority jobs like sending notifications and some low priority jobs like a long running script updating some data. I think it will be great to have a priority setup in this module so that high priority jobs can be executed first.

    I hope I will see some feedback from you regarding this.

    Thank you

    opened by altafhussain10 6
  • Command

    Command "queue:consumers:start" is not defined in Magento version 2.3.x

    This topic is directly related to #12

    Rcason_Mq modules were a great thing up to Magento 2.3 but seems to conflict somehow with last Magento 2 editions causing new queue:consumers:start command from \Magento\MessageQueue\Console\StartConsumerCommand class not to run leaving following info in system.log with each CRON execution:

    [2020-04-25 22:39:08] main.ERROR: Command "queue:consumers:start" is not defined.
    
    Did you mean one of these?
        ce_mq:consumers:start
        queue:consumers:list
    #0 /home/magento2/www/vendor/symfony/console/Application.php(226): Symfony\Component\Console\Application->find('queue:consumers...')
    #1 /home/magento2/www/vendor/magento/framework/Console/Cli.php(115): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
    #2 /home/magento2/www/vendor/symfony/console/Application.php(145): Magento\Framework\Console\Cli->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
    #3 /home/magento2/www/bin/magento(23): Symfony\Component\Console\Application->run()
    #4 {main} [] []
    [2020-04-25 22:39:08] main.ERROR: Command "queue:consumers:start" is not defined.
    

    Did I miss something? I've had to remove:

    -        "renatocason/magento2-module-mq": "^1.1",
    -        "renatocason/magento2-module-mq-amqp": "^1.1",
    -        "renatocason/magento2-module-mq-mysql": "^1.2"
    

    from composer.json to bring back my Magento 2 instances new, built in operations:

    product_action_attribute.update
    product_action_attribute.website.update
    exportProcessor
    codegeneratorProcessor
    async.operations.all
    

    lack of which caused products exports not to work anymore.

    opened by Tomasz-Silpion 4
  • Declare compatibility with PHP 7.2 in releases for Magento 2.2.x

    Declare compatibility with PHP 7.2 in releases for Magento 2.2.x

    Hello.

    For a project we are developing, we chose your module to ensure Message Queue support on Magento 2.2.11, to replace Magento's native one which isn't available in the Open Source edition.

    The issue we're having is that installing the module via composer on our environments with Magento 2.2.11 is currently impossible:

    • Picking a 1.1.x release (1.2.x in the case of the MySQL adapter) results in a conflict with the Magento Framework's version (which is normal, since it's for Magento 2.3 without declared backwards compatibility)
    • Picking a 1.0.x release (1.1.x in the case of the MySQL adapter) results in a conflict with the PHP version, since the module is declared as compatible with PHP 7.0 and 7.1 only.

    As of 2.2.11, Magento supports PHP 7.2, as seen here: https://github.com/magento/magento2/blob/2.2.11/composer.json . By downloading the base module and both MySQL and AMQP adapters, and placing them in app/code instead, it works, I could successfully send and receive messages via both methods without any issues.

    Is it possible to please declare a compatibility with PHP 7.2 in Magento 2.2.x releases in the base module and both MySQL and AMQP adapters?

    opened by AlexandreKhayrullin 3
  • Thoughts on using Magento's built-in cron?

    Thoughts on using Magento's built-in cron?

    Good day,

    I was wondering what your thoughts are on using Magento's built-in cron, rather than running commands from the command line.

    The reason why I'm considering this is because we don't have control over our customers' systems and therefore cannot ensure that queues are running, whereas Magento's built-in cron automatically runs every minute so we could use that instead.

    I'm looking at mq-mysql and I'm thinking that if I created a cron task which, once per minute, detects whether a previous queue process is running (somehow) and basically does what StartConsumerCommand does in fetching the broker, consumer, etc.

    What are your thoughts on this? Can you foresee negative side-effects I haven't considered?

    Thank you.

    opened by mlambley 3
  • Compare with Magento 2.3 message queue

    Compare with Magento 2.3 message queue

    Since Magento 2.3 release, they have migrated message queue to Community version and their built-in message queue implementation support RabbitMQ as well. So do you have any comparison for cons and pros for using this module instead of built-in one?

    opened by onlinebizsoft 2
  • Consumer does not run after deployment

    Consumer does not run after deployment

    Hi @renatocason,

    We're facing an issue with the consumer. We start it like this;

    nohup php bin/magento ce_mq:consumers:start lcp.product.prewarm &> /data/web/current/var/log/consumer_prewarm.log &
    

    But when we do a deployment, the current symlink (which the public folder points to) will point to the new deployment. At that point, the process does keep running, but it doesn't work anymore.

    Do you have an idea how to circumvent this? Right now, we kill the process every 5 minutes and restart it through a cron, which kinda defeats the purpose of a consumer.

    opened by peterjaap 2
  • Area code is not set

    Area code is not set

    Running a consumer via the command line produces the following error:

    Error processing message: Area code is not set
    

    Looks like it's coming from the \Magento\Framework\App\State. I've seen this issue pop up in other third-party modules that introduce custom CLI commands. I'll open up a PR shortly

    opened by grafikchaos 2
  • add support for magento version 2.3.3 and php version 7.3

    add support for magento version 2.3.3 and php version 7.3

    Hi Renato, i updated the Module for the update to Magento 2.3.3 and update to php version 7.3. I tested it and for me it works.

    Looks like i missed to update the travis.yml.

    opened by jonathan-martz 1
  • xml message Schema

    xml message Schema

    Hello,

    What value we can put in place of "int" in the ce_mq.xml file : messageSchema="int", can we put json or text/plain ? i tried to chage but not working.

    thank you.

    opened by bouzakherOR 1
  • Magento 2.4 compatibility

    Magento 2.4 compatibility

    Hello, version 1.1.4 is not yet compatible with Magento 2.4. Is there something planned soon? Otherwise I would have to look around for another extension. Greetings, Marco.

    opened by luebke 1
  • Please add a retry interval for failed jobs

    Please add a retry interval for failed jobs

    Right now when I have a job that fails (throws an Exception) and is requeued, the system immediately attempts to run it $maxRetries times and then fails altogether.

    In the case where the error is caused by a network issue or a third-party system being down, waiting an amount of time before trying again would be beneficial.

    I suggest implementing a field in mq-mysql\Api\Data\QueueMessageInterface named something like run_task_at. That way tasks can be scheduled to run in the future. And then have a retry interval, perhaps a number of seconds, configurable in StartConsumerCommand (and preferably the ceQueue xml as well - see https://github.com/renatocason/magento2-module-mq/issues/16).

    I haven't looked into your mq-amqp module but I imagine that a similar thing could be implemented there too.

    Thank you.

    opened by mlambley 0
  • Include cli parameters in ceQueue definition

    Include cli parameters in ceQueue definition

    Could the ceQueue definition include, optionally, the fields interval, limit, requeue, runonce?

    Something like:

    <ceQueue name="product.updates" broker="mysql"
        messageSchema="int"
        consumerInterface="Rcason\MqExample\Model\ExampleConsumer" 
        interval="250"
        limit="1200"
        requeue="1"
        runonce="0"
    />
    

    And then in StartConsumerCommand if those options are not specified on the command line, it looks for them in the xml, and if not found in either the command line or the xml then it uses the default values?

    Thanks.

    opened by mlambley 2
  • Consider using queue interprop as abstraction for queues

    Consider using queue interprop as abstraction for queues

    Hello!

    Please look at https://github.com/queue-interop/queue-interop project. Using interfaces from it allows us reuse some implementations like enqueue, which supports a lot of transports. You can outsource some code

    opened by Koc 0
Releases(1.1.4)
Owner
Renato
Renato
Promoting the interoperability of message queue objects.

Queue Interoperability About queue-interop tries to identify and standardize a common way for PHP programs to create, send, receive and read MQ messag

null 446 Jan 3, 2023
Magento 2 Module Experius Page Not Found 404. This module saves all 404 url to a database table

Magento 2 Module Experius Page Not Found 404 This module saves all 404 urls to a database table. Adds an admin grid with 404s It includes a count so y

Experius 28 Dec 9, 2022
Automatically load the next page of products in Magento. Easy to install and configure, this module works 100% out of the box with vanilla Magento 1.9.x and earlier.

Automatically load the next page of products in Magento. Easy to install and configure, this module works 100% out of the box with vanilla Magento 1.9.x and earlier.

Strategery 123 Nov 20, 2021
A tool that allows to quickly export data from Magento 1 and Magento 2 store and import it back into Magento 2

Simple Import / Export tool A tool that allows to quickly export data from Magento 1 and Magento 2 store and import it back into Magento 2. Table data

EcomDev B.V. 51 Dec 5, 2022
Beanstalk is a simple, fast work queue.

beanstalkd Simple and fast general purpose work queue. https://beanstalkd.github.io/ See doc/protocol.txt for details of the network protocol. Please

Beanstalkd 6.3k Jan 6, 2023
Use php-fpm as a simple built-in async queue

PHP-FPM Async Queue Use php-fpm as a simple built-in async queue. Based on interoperable queue interfaces Queue Interop. Usage composer makasim/php-fp

Max Kotliar 111 Nov 19, 2022
Queue Management Systems for LPG vendor agencies of Sri Lanka, for the LPG shortages in 2022

gas-queue-mgt Queue Management Systems for LPG vendor agencies of Sri Lanka, for the LPG shortages in 2022 Installation Requirements PHP 7.4 or later

Madhusanka Goonathilake 14 Oct 18, 2022
A lightweight queue based on Redis Stream for webman plugin.

workbunny/webman-rqueue ?? A lightweight queue based on Redis Stream for webman plugin. ?? A lightweight queue based on Redis Stream for webman plugin

workbunny 10 Dec 12, 2022
PHP library for Disque, an in-memory, distributed job queue

disque-php A PHP library for the very promising disque distributed job queue. Features: Support for both PHP (5.5+) and HHVM No dependencies: Fast con

Mariano Iglesias 132 Oct 19, 2022
PHP Web User Queue designed to run on shared hosting

WebUserQueue Introduction This is a web user queueing system written in PHP with a MySQL backend designed to run on shared hosting. It was designed to

Chris 0 Aug 13, 2022
Fully covered with tests, documented by Swagger and dockerized API based on enterprise-level framework with optional queue worker.

symfony-api Fully covered with tests, documented by Swagger and dockerized API based on enterprise-level framework with optional queue worker. ⚙️ Depl

Oleksii Velychko 1 Nov 20, 2022
PHP Lightweight Message Bus supporting CQRS.

Prooph Service Bus PHP 7.1+ lightweight message bus supporting CQRS and Micro Services Important This library will receive support until December 31,

null 440 Nov 20, 2022
Xenon\LaravelBDSms is a sms gateway package for sending text message to Bangladeshi mobile numbers using several gateways like sslcommerz, greenweb, dianahost,metronet in Laravel framework

Xenon\LaravelBDSms is a sms gateway package for sending text message to Bangladeshi mobile numbers using several gateways for Laravel. You should use

Ariful Islam 95 Jan 3, 2023
Get dialogflow fullfilment message in PHP

dialogflow-php PHP Client Library for Dialogflow API v2 Requirements Dialogflow Agent Google Account Credentials file PHP Composer Installation To beg

Emmadi Sumith Kumar 17 Oct 28, 2022
This is an implementation of PSR specification. It allows you to send and consume message with Redis store as a broker.

This is an implementation of PSR specification. It allows you to send and consume message with Redis store as a broker.

Enqueue 35 Nov 4, 2022
Ask your friends to send you an anonymous message without knowing them

Ask your friends to send you an anonymous message without knowing them. ????????

Siavash 1 Apr 16, 2022
⚡ Php snippets, random stuff, demos, functions, fast message system, agnostic and framework free - 100% compactible ;) ⚡

⚡ Php8 FPM Nginx Fast, Scripts, Pearls & Treasures ?? Want to run and test asap ? docker-compose up -d phpgit_php8;ip=$(docker-machine ip default);ech

Benjamin FONTAINE 0 Mar 20, 2022