How-to check RabbitMQ on Cloud

If you configured our module to works with the RabbitMQ, but our sync Queue is not processed - youneed to check a few points.

 

Related article: https://devdocs.magento.com/cloud/project/services-rabbit.html

 

1. Make sure you check the correct Magento cloud instance.

First, you need connect to your Magento via ssh. Make sure you are looking at the same instance in the browse and via ssh.

2. Check Cloud instance configured for RabbitMQ

Connect to your Magento cloud via ssh and check configuration files:

  • .magento.app.yaml - it should contains information about the rabbitqm, here is an example:

    ... relationships: database: "mysql:mysql" redis: "redis:redis" elasticsearch: "elasticsearch:elasticsearch" rabbitmq: "rabbitmq:rabbitmq" ...

 

  • app/etc/env.php - it should contains connection credentials for the rabbitmq

    'queue' => array ( 'amqp' => array ( 'host' => 'localhost', 'port' => '5672', 'user' => '***', 'password' => '***', 'virtualhost' => '***', ) ),

 

3. Make sure the rabbitmq credentials are correct

You can configure port forwarding for your local computer to the Magento server and check rabbitmq via browser as it described here: https://devdocs.magento.com/cloud/project/services-rabbit.html#cloud-rabbitmq-conn-loc

But some times it doesn’t work because of your local network security. In this case you can use our instruction here:

  • Connect to your Magento cloud via ssh

  • Use the credentials from your app/etc/env.php file and run the next command:

    curl -s -u <user>:<password> http://<host>:<port>/api/queues

If your credentials are correct - you should receive big json with the Queues information

  • Make sure the response contains our queue names:

    • tnw_salesforce_sync_realtime

    • tnw_salesforce.queue.process.amqp

    • tnw_salesforce.prequeue.process.amqp

If you did not find our Queue names - you need to run the “setup:upgrade“ and “setup:di:compile“ commands: https://devdocs.magento.com/guides/v2.4/reference/cli/magento-commerce.html. For the Cloud instance - run the redeploy process:

 

4. Check our Rabbit Queues message count

Run the next commands to get message count for every our Queue:

 

If your virtualhost = “/“ - you need to define in in the command as “%2F“, i.e. it will looks like:

curl -s -i -u guest:guest http://localhost:15672/api/queues/%2F/tnw_salesforce_sync_realtime|sed 's/,/\n/g' | grep '"messages"' | sed 's/"messages"://g'

 

The point is: if you have a few scheduled records in the sync Queue, but the related Rabbit Queue is empty or keep the same message count - it means you need to reset a few related sync Queue Items. I’ll start RabbitMQ message creation.

5. Reset a few sync Queue items to start RabbitMQ messages generation:

  • Go to the Magento Admin area, open our module settings and enable Develop mode:

You may need to refresh your store cache when

 

  • In our module menu a new item will be available: “From Magento (old)”

     

  • One the old Queue page send a few items to the Re-sync

  • Do the Re-sync one more time with another items

 

Result: our module will start push messages to the Rabbit.