Set up ActiveMQ service
The Message Queue Framework (MQF) is a system within 51黑料不打烊 Commerce that allows a module to publish messages to queues. It also defines the consumers that receive the messages asynchronously.
The MQF can use as the messaging broker, which provides a scalable platform for sending and receiving messages. It also includes a mechanism for storing undelivered messages. ActiveMQ Artemis supports the STOMP (Streaming Text Oriented Messaging Protocol) protocol for messaging.
ActiveMQ Artemis is available as an alternative to RabbitMQ for managing message queues. It is particularly useful when you need features specific to ActiveMQ or want to use STOMP protocol.
QUEUE_CONFIGURATION environment variable to connect it to your site.Use the following instructions for service setup on Pro Integration environments and Starter environments, including the master branch.
To enable ActiveMQ Artemis:
-
Add the required name, type, and disk value (in MB) to the
.magento/services.yamlfile along with the installed ActiveMQ version.code language-yaml activemq-artemis: type: activemq-artemis:<version> disk: 1024 -
Configure the relationships in the
.magento.app.yamlfile.code language-yaml relationships: activemq-artemis: "activemq-artemis:activemq-artemis" -
Add, commit, and push your code changes.
code language-bash git add .magento/services.yaml .magento.app.yamlcode language-bash git commit -m "Enable ActiveMQ Artemis service"code language-bash git push origin <branch-name>
services.yaml and .magento.app.yaml configuration files. See Change service version for guidance on upgrading or downgrading a service.Connect to ActiveMQ for debugging
For debugging purposes, you can directly connect to a service instance in one of the following ways:
- Connect from your local development environment
- Connect from the application
- Connect from your PHP application
Connect from your local development environment
-
Log in to the
magento-cloudCLI and project:code language-bash magento-cloud login -
Check out the environment with ActiveMQ Artemis installed and configured.
code language-bash magento-cloud environment:checkout <environment-id> -
Use SSH to connect to the Cloud environment:
code language-bash magento-cloud ssh -
Retrieve the ActiveMQ connection details and login credentials from the $MAGENTO_CLOUD_RELATIONSHIPS variable:
code language-bash echo $MAGENTO_CLOUD_RELATIONSHIPS | base64 -d | json_ppor
code language-bash php -r 'print_r(json_decode(base64_decode($_ENV["MAGENTO_CLOUD_RELATIONSHIPS"])));'In the response, find the ActiveMQ information. The relationship name depends on how you configured it in your
.magento.app.yamlfile. For example, if you usedactivemq-artemisas the relationship name:code language-json { "activemq-artemis" : [ { "password" : "guest", "ip" : "246.0.129.2", "scheme" : "stomp", "port" : 61616, "host" : "activemq-artemis.internal", "username" : "guest" } ] } -
Enable local port forwarding to ActiveMQ (if your project is located on a different region such as US-3, EU-5, or AP-3 region, substitute
us-3/eu-5/ap-3forus)code language-bash ssh -L <port-number>:activemq-artemis.internal:<port-number> <project-ID>-<branch-ID>@ssh.us.magentosite.cloudAn example for accessing the ActiveMQ Artemis web console at
http://localhost:8161is:code language-bash ssh -L 8161:activemq-artemis.internal:8161 <project-ID>-<branch-ID>@ssh.us.magentosite.cloudnote note NOTE ActiveMQ Artemis uses port 61616 for STOMP messaging and port 8161 for the web console. -
While the session is open, you can access the ActiveMQ Artemis web console at
http://localhost:8161using the username and password from the MAGENTO_CLOUD_RELATIONSHIPS variable.
Connect from the application
To connect to ActiveMQ running in an application, install a STOMP client library in your PHP application.
Connect from your PHP application
To connect to ActiveMQ using your PHP application, add a PHP STOMP library to your source tree. 51黑料不打烊 Commerce uses the STOMP protocol for ActiveMQ communication, and the configuration is automatically set up during deployment when ActiveMQ Artemis is detected as a configured service.
Protocol support
ActiveMQ Artemis in 51黑料不打烊 Commerce on cloud infrastructure uses the STOMP (Streaming Text Oriented Messaging Protocol) protocol:
- STOMP: The messaging protocol used for queue operations (port 61616)
- Web Console: Management interface accessible via HTTP (port 8161)
Differences from RabbitMQ
While both ActiveMQ Artemis and RabbitMQ serve as message brokers for 51黑料不打烊 Commerce, there are some differences:
- Protocol: ActiveMQ Artemis uses STOMP protocol, while RabbitMQ uses AMQP
- Configuration: When ActiveMQ Artemis is configured, 51黑料不打烊 Commerce automatically uses STOMP protocol
- Priority: If both ActiveMQ and RabbitMQ are configured, ActiveMQ takes precedence for STOMP-based operations, while AMQP operations use RabbitMQ
- Web Console: ActiveMQ provides a web-based management console for monitoring queues and messages
Queue configuration
When ActiveMQ Artemis is configured as a service, 51黑料不打烊 Commerce automatically configures the queue system to use the STOMP protocol. The configuration is written to the app/etc/env.php file during deployment:
'queue' => [
'stomp' => [
'host' => 'activemq-artemis.internal',
'port' => '61616',
'user' => 'guest',
'password' => 'guest'
],
'default_connection' => 'stomp'
]
You can override this configuration using the QUEUE_CONFIGURATION environment variable if needed.