How to Configure Magestore POS using RabbitMQ on Magento


1. RabbitMQ is installed and connected to Magento.

The image below shows that RabbitMQ is connected with Magento, if the queue “async.operations.all” does not display as the image, that means RabbitMQ cannot connect to Magento, please follow the instructions to install RabbitMQ from Magento to configure it.

2. Magestore POS supports message queue

  • POS Enterprise Commerce >=v4.8.0

  • POS Enterprise >=v4.13.8

  • POS Pro Commerce >=v4.5.0

  • POS Pro >=v4.15.0

Read more: How to check your POS version from the backend, to know which version of Magestore POS you are using.

3. Magento Cron is configured and running


1. Configure the env . file

  1. Open file app/etc/env.php

  2. Find the key ‘cron_consumers_runner’ in the file

  • If there is no key ‘cron_consumers_runner’ in the file, add the below config, place to the same level as the key ‘queue’

1 2 3 4 5 6 7 … 'cron_consumers_runner' => [ 'cron_run' => true, 'max_messages' => 0, 'consumers' => [] ], …
  • If the file already has the key ‘cron_consumers_runner’, and the array ‘consumers’ already has the value, then it needs  magestore_pos_process_order.convert.consumerto be appended to the end of the array.

Note: If there is no key ‘consumers’ or there is but an empty array, then no need to modify anything because by default all consumers are allowed.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 … 'cron_consumers_runner' => [ 'cron_run' => true, 'max_messages' => 0, 'consumers' => [ 'async.operations.all', 'codegeneratorProcessor', 'product_action_attribute.update', '', 'exportProcessor', 'magestore_pos_process_order.convert.consumer' ] ], …
  1. Find the key ‘queue’ > ‘consumers_wait_for_messages’ in the file, switch back to 

0, if not, add as below

1 2 3 4 5 … 'queue' => [ 'consumers_wait_for_messages' => 0, ], …
  1. Save the file

After editing it will look like the image below 

Notes: See more suggestions from Magento

2. Edit message queue configuration in Webpos module

1. File: app/code/Magestore/Webpos/etc/queue.xml
  • Tag “broker”

    • Attribute “exchange” change from “magento-db” to “magento”

    • Attribute “type” change from “db” to “amqp”

File content after being changed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 <?xml version="1.0"?> <!-- /** * Copyright © Magestore, Inc. All rights reserved. * See COPYING.txt for license details. */ --> <config xmlns:xsi="" xsi:noNamespaceSchemaLocation="urn:magento:framework-message-queue:etc/queue.xsd"> <broker topic="magestore_pos_process_order.convert.topic" exchange="magento" type="amqp"> <queue name="magestore_pos_process_order.convert.queue" consumer="magestore_pos_process_order.convert.consumer" consumerInstance="Magento\Framework\MessageQueue\Consumer" handler="Magestore\Webpos\Model\Checkout\PosOrder\Consumer::execute"/> </brok </config> , you may need to do some additional configuration as below sesion in the Magento Backend.From the Admin Menu go to System > MageMojo > Cron Settings, edit the following fields:FIELDVALUEEXPLAINCron EnabledYes (Checked)Turn on MageMojo CronMaximum Cron Processes3 (If already a number greater than 3, keep it)Running multiple cron threads in parallel helps handle more workload (If set to 1, the convert order thread has to wait for other threads to complete before it can be run, resulting in a long wait time for the conversion order).Consumers Job Timeout600 (If already a larger number, keep it)Avoid the order that is being converted to be terminated, leading to the error that the shipment and payment cannot be saved, because the timeout time is too short.Consumers GovenorNo (UnChecked)Avoid MageMojo to terminate the conversion order process when the consumer is converting the order.Then click the “Save” button.Settings after being changed3. Run commandsphp bin/magento maintenance:enable php bin/magento cron:remove php bin/magento setup:upgrade php bin/magento setup:di:compile php bin/magento setup:static-content:deploy -f -j 10 php bin/magento cache:flush php bin/magento cron:install php bin/magento maintenance:disable4. ResultAdvanced configurationBy default, the message queue will run single-thread, which that means, 1 consumer can only create 1 worker at a time. In case your transaction is too much, the worker will not be able to process it in time, leading to the converting to Magento Order is slower because of the long queue. To solve this problem, Magestore POS has a mechanism to run multiple workers.Run the following command to change configphp bin/magento config:set --lock-env webpos/order_converter/number_of_thread_worker 3Run the following commands to apply configphp bin/magento maintenance:enable php bin/magento cron:remove php bin/magento setup:upgrade php bin/magento cache:flush php bin/magento cron:install php bin/magento maintenance:disableThe number of workers refers to the table below