Magento 2.0.18 is the final 2.0.x release. After March 2018, Magento 2.0.x will no longer receive security patches, quality fixes, or documentation updates.
To maintain your site's performance, security, and PCI compliance, upgrade to the latest version of Magento.

Manage message queues

If you don’t want to implement the RabbitMQ solution, you can manage message queues with cron jobs (or an external process manager) and the command line to ensure that consumers are retrieving messages.

Process management

Cron jobs are the default mechanism to restart consumers. Processes started by cron consume the specified number of messages and then terminate. Re-running cron restarts the consumer.

A magic method, whose name is the same as the consumer name, is used as a callback when declaring a new consumer run job in crontab.xml. Using magic methods allows you to pass the name of the consumer implicitly via method name. Alternatively, virtual types based on abstract consumer runner should be declared with a concrete consumer name specified as an argument (this approach is more complex and requires extra configuration).

The following shows a crontab group entry:

<group id="default">
    <job name="consumerCustomerCreatedListener" instance="Magento\Amqp\Model\ConsumerRunner" method="customerCreatedListener">
        <schedule>0 0 * * *</schedule>

How often you check message queues depends on your business logic and available system resources. In general, you’ll probably want to check for newly created customers and send welcome emails more frequently than a more resource intensive process (e.g., updating your catalog). You should define cron schedules according to your business needs.

See Configure and run cron for more information about using cron with Magento.

You can also use a process manager, such as Supervisor, to monitor the status of processes. The manager can use the command line to restart processes as needed.

Command line interface

Start consumers

Use the magento command to start message queue consumers. You can start multiple consumers simultaneously.

./bin/magento queue:consumers:start <consumer_name> [--max-messages=<value>]

where <consumer_name> is the consumer to start and --max-messages=<value> specifies the maximum number of messages to consume per invocation.

If the number of queued messages is less than the specified max, the consumer polls for new messages until it has processed the max. If you don’t specify --max-messages, the process runs continuously.

After consuming all available messages, the command terminates. You can run the command again manually or with a cron job. You can also run multiple instances of the magento queue:consumers:start command to process large message queues. For example, you can append & to the command to run it in the background, return to a prompt, and continue running commands (e.g., bin/magento queue:consumers:start <consumer_name> &).

List consumers

Use the following command to return a list of message queue consumers:

./bin/magento queue:consumers:list