Skip to content

Latest commit

 

History

History
148 lines (104 loc) · 4.97 KB

services-rabbit.md

File metadata and controls

148 lines (104 loc) · 4.97 KB
group title functional_areas redirect_from redirect_to status
cloud-guide
Set up RabbitMQ service
Cloud
Setup
/cloud/project/project-conf-files_services-rabbit.html
migrated

The [Message Queue Framework (MQF)]({{ site.baseurl }}/guides/v2.3/config-guide/mq/rabbitmq-overview.html) is a system within {{site.data.var.ee}} that allows a module to publish messages to queues. It also defines the consumers that will receive the messages asynchronously.

The MQF uses RabbitMQ as the messaging broker, which provides a scalable platform for sending and receiving messages. It also includes a mechanism for storing undelivered messages. RabbitMQ is based on the Advanced Message Queuing Protocol (AMQP) 0.9.1 specification.

{:.bs-callout-warning} If you prefer using an existing AMQP-based service, like RabbitMQ, instead of relying on {{site.data.var.ece}} to create it for you, use the [QUEUE_CONFIGURATION]({{ site.baseurl }}/cloud/env/variables-deploy.html#queue_configuration) environment variable to connect it to your site.

{% include cloud/service-config-integration-starter.md %}

{:.procedure} To enable RabbitMQ:

  1. Add the required name, type, and disk value (in MB) to the .magento/services.yaml file along with the installed RabbitMQ version.

    rabbitmq:
        type: rabbitmq:<version>
        disk: 1024
  2. Configure the relationships in the .magento.app.yaml file.

    relationships:
        rabbitmq: "rabbitmq:rabbitmq"
  3. Add, commit, and push your code changes.

    git add -A
    git commit -m "Enable RabbitMQ service"
    git push origin <branch-name>
  4. [Verify the service relationships]({{ site.baseurl }}/cloud/project/services.html#service-relationships).

For information on how these changes affect your environments, see [services.yaml]({{ site.baseurl }}/cloud/project/services.html).

{% include cloud/tip-change-installed-service-version.md %}

Connect to RabbitMQ for debugging {#connect}

For debugging purposes, it is useful to directly connect to a service instance in one of the following ways:

Connect from your local development environment {#cloud-rabbitmq-conn-loc}

  1. Log in to the magento-cloud CLI and project:

    magento-cloud login
  2. Checkout the environment with RabbitMQ installed and configured.

    magento-cloud environment:checkout <environment-id>
  3. Use SSH to connect to the Cloud environment:

    magento-cloud ssh
  4. Retrieve the RabbitMQ connection details and login credentials from the [$MAGENTO_CLOUD_RELATIONSHIPS]({{ site.baseurl }}/cloud/project/magento-app-properties.html#relationships) variable:

    echo $MAGENTO_CLOUD_RELATIONSHIPS | base64 -d | json_pp

    or

    php -r 'print_r(json_decode(base64_decode($_ENV["MAGENTO_CLOUD_RELATIONSHIPS"])));'

    In the response, find the RabbitMQ information, for example:

    {
       "rabbitmq" : [
          {
             "password" : "guest",
             "ip" : "246.0.129.2",
             "scheme" : "amqp",
             "port" : 5672,
             "host" : "rabbitmq.internal",
             "username" : "guest"
          }
       ]
    }

    {:.no-copy}

  5. Enable local port forwarding to RabbitMQ.

    ssh -L <port-number>:rabbitmq.internal:<port-number> <project-ID>-<branch-ID>@ssh.us.magentosite.cloud

    An example for accessing the RabbitMQ management web interface at http://localhost:15672 is:

    ssh -L 15672:rabbitmq.internal:15672 <project-ID>-<branch-ID>@ssh.us.magentosite.cloud
  6. While the session is open, you can start a RabbitMQ client of your choice from your local workstation, configured to connect to the localhost:<portnumber> using the port number, username, and password information from the MAGENTO_CLOUD_RELATIONSHIPS variable.

Connect from the application {#cloud-rabbitmq-conn-cont}

To connect to RabbitMQ running in an application, you need to install a client such as amqp-utils as a project dependency in your .magento.app.yaml file.

For example,

dependencies:
    ruby:
        amqp-utils: "0.5.1"

Then, when you log in to your PHP container, you enter any amqp- command available to manage your queues.

Connect from your PHP application {#cloud-rabbitmq-conn-php}

To connect to RabbitMQ using your PHP application, add a PHP library (like PHP AMQPlib) to your source tree.