Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 30 additions & 1 deletion src/pages/coding-standards/js.md
Original file line number Diff line number Diff line change
Expand Up @@ -361,4 +361,33 @@ var foo = 'bar',

There is a set of custom Eslint rules to ensure code compatibility with the latest versions of third-party libraries.

These custom rules are included using the `rulePaths` setting in the [Eslint Grunt configuration](https://github.com/magento/magento2/blob/2.4/dev/tools/grunt/configs/eslint.json).
In previous versions of ESLint, these custom rules were included using the `rulePaths` setting in the [ESLint Grunt configuration](https://github.com/magento/magento2/blob/2.4/dev/tools/grunt/configs/eslint.json).

However, since ESLint 9 has deprecated `rulePaths`, you must update the configuration accordingly.

The following example shows the necessary changes to implement custom Eslint rules in the `dev/tools/grunt/configs/eslint.json` file.

```json
{
"file": {
"options": {
"overrideConfigFile": "vendor/magento/magento-coding-standard/eslint/eslint.config.mjs",
"useEslintrc": false
}
},
"test": {
"options": {
"overrideConfigFile": "vendor/magento/magento-coding-standard/eslint/eslint.config.mjs",
"outputFile": "dev/tests/static/eslint-error-report.xml",
"format": "junit",
"quiet": true
}
}
}
```

### Applying custom rules

To add or modify custom rules, update the `eslint.config.mjs` file in the `magento-coding-standard` repository.
In the latest version of ESLint, the configuration has transitioned from using the legacy `.eslintrc` settings to the new flat configuration.
Refer to the [migration guide](https://eslint.org/docs/latest/use/configure/migration-guide) in the ESlint documentation for detailed instructions on migrating to the new format.
Original file line number Diff line number Diff line change
Expand Up @@ -46,28 +46,36 @@ The `queue_publisher.xml` file is generated by the `\Magento\WebapiAsync\Code\Ge

The sort order is set to 0 and allows developers to change some aspects of the generated configuration in configuration readers such as `queue_publisher.xml` and `env.php`.

`\Magento\WebapiAsync\Code\Generator\Config\RemoteServiceReader\Publisher::read()` calls `\Magento\AsynchronousOperations\Model\ConfigInterface::getServices()` to get an array of all REST API routes which can be executed asynchronously. Then it defines the connection name as `amqp` and the exchange as `magento` for each generated topic name.
`\Magento\WebapiAsync\Code\Generator\Config\RemoteServiceReader\Publisher::read()` calls `\Magento\AsynchronousOperations\Model\ConfigInterface::getServices()` to get an array of all REST API routes which can be executed asynchronously. Then it defines the connection name as `amqp` (or `stomp` for ActiveMQ Artemis) and the exchange as `magento` for each generated topic name.

## queue_consumer.xml

The asynchronous/bulk API has one defined consumer which processes all asynchronous/bulk APIs messages.

```xml
<consumer name="async.operations.all" queue="async.operations.all" connection="amqp"
<consumer name="async.operations.all" queue="async.operations.all"
consumerInstance="Magento\AsynchronousOperations\Model\MassConsumer"/>
```

The connection type (AMQP or STOMP) is determined automatically based on your `env.php` configuration.

### queue_topology.xml

The message queue topology configuration links all auto-generated topic names with prefix `async.` to the `magento` exchange and defines the queue named `async.operations.all` as the destination for all messages.

```xml
<exchange name="magento" connection="amqp">
<exchange name="magento">
<binding id="async.operations.all" topic="async.#" destination="async.operations.all"/>
</exchange>
```

The connection type is automatically determined from your `env.php` configuration.

<InlineAlert variant="info" slots="text"/>

Message queues connection is defined dynamically based on deployment configuration in `env.php`. If AMQP or STOMP is configured in deployment configuration of the queue, the respective connection is used. Otherwise, db connection is used.
As a result, if AMQP or STOMP is configured in deployment configuration of the queue, connection declaration can be omitted in [message queue configuration files](./configuration.md): `queue_customer.xml`, `queue_publisher.xml`, `queue_topology.xml`.

<InlineAlert variant="info" slots="text"/>

Message queues connection is defined dynamically based on deployment configuration in `env.php`. If AMQP is configured in deployment configuration of the queue, AMQP connection is used. Otherwise, db connection is used.
As a result, if AMQP is configured in deployment configuration of the queue, connection declaration can be omitted in [message queue configuration files](./configuration.md): `queue_customer.xml`, `queue_publisher.xml`, `queue_topology.xml`.
ActiveMQ Artemis (STOMP) was introduced in Adobe Commerce 2.4.6 and later versions. For STOMP connections, use ANYCAST addressing mode for point-to-point message delivery and load balancing across multiple consumers.
Original file line number Diff line number Diff line change
Expand Up @@ -319,35 +319,55 @@ The `queue_consumer.xml` file defines the relationship between a queue and its c

```xml
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework-message-queue:etc/consumer.xsd">
<consumer name="<consumer_name>" queue="<queue_name>" connection="amqp" consumerInstance="Magento\Framework\MessageQueue\Consumer" handler="<Consumer_Class>::<Consumer_method>"/>
<consumer name="<consumer_name>" queue="<queue_name>" consumerInstance="Magento\Framework\MessageQueue\Consumer" handler="<Consumer_Class>::<Consumer_method>"/>
</config>
```

The connection type (AMQP or STOMP) is determined automatically based on your `env.php` configuration.

### Create `queue_publisher.xml`

The `queue_publisher.xml` file defines the exchange where a topic is published. Create this file with the following contents:

**For RabbitMQ (AMQP):**

```xml
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework-message-queue:etc/publisher.xsd">
<publisher topic="<topic_name>">
<connection name="amqp" exchange="<exchange>" />
<connection exchange="<exchange>" />
</publisher>
</config>
```

**For ActiveMQ Artemis (STOMP):**

```xml
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework-message-queue:etc/publisher.xsd">
<publisher topic="<topic_name>" queue="<queue_name>" />
</config>
```

**Note**: For ActiveMQ Artemis, the `<connection>` element is not required as the connection type is determined from `env.php`. When the topic name and queue name are different, you must specify the `queue` attribute in the `<publisher>` element.

### Create `queue_topology.xml`

The `queue_topology.xml` file defines the message routing rules and declares queues and exchanges. Create this file with the following contents:

```xml
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework-message-queue:etc/topology.xsd">
<exchange name="magento" type="topic" connection="amqp">
<exchange name="magento" type="topic">
<binding id="defaultBinding" topic="" destinationType="queue" destination="<queue_name>"/>
</exchange>
</config>
```

The connection type is automatically determined from your `env.php` configuration.

<InlineAlert variant="info" slots="text"/>

Message queue connections are defined dynamically, based on the deployment configuration in the `env.php` file. If AMQP or STOMP is configured in the deployment configuration of the queue, the respective connection is used. Otherwise, database connections are used.
As a result, if AMQP or STOMP is configured in the deployment configuration of the queue, you can omit connection declarations in the `queue_consumer.xml`, `queue_publisher.xml`, and `queue_topology.xml` [message queue configuration files](./configuration.md).

<InlineAlert variant="info" slots="text"/>

Message queue connections are defined dynamically, based on the deployment configuration in the `env.php` file. If AMQP is configured in the deployment configuration of the queue, AMQP connections are used. Otherwise, database connections are used.
As a result, if AMQP is configured in the deployment configuration of the queue, you can omit connection declarations in the `queue_consumer.xml`, `queue_publisher.xml`, and `queue_topology.xml` [message queue configuration files](./configuration.md).
ActiveMQ Artemis (STOMP) was introduced in Adobe Commerce 2.4.6 and later versions. For STOMP connections, use ANYCAST addressing mode for point-to-point message delivery and load balancing across multiple consumers.
36 changes: 29 additions & 7 deletions src/pages/development/components/message-queues/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Depending on your needs, you may only need to create and configure `communicatio

## `communication.xml`

The `<module>/etc/communication.xml` file defines aspects of the message queue system that all communication types have in common. This release supports AMQP and database connections.
The `<module>/etc/communication.xml` file defines aspects of the message queue system that all communication types have in common. This release supports AMQP, STOMP, and database connections.

### Example

Expand Down Expand Up @@ -81,8 +81,8 @@ The `queue_consumer.xml` file contains one or more `consumer` elements:
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework-message-queue:etc/consumer.xsd">
<consumer name="basic.consumer" queue="basic.consumer.queue" handler="LoggerClass::log"/>
<consumer name="synchronous.rpc.test" queue="synchronous.rpc.test.queue" handler="LoggerClass::log"/>
<consumer name="rpc.test" queue="queue.for.rpc.test.unused.queue" consumerInstance="Magento\Framework\MessageQueue\BatchConsumer" connection="amqp"/>
<consumer name="test.product.delete" queue="queue.for.test.product.delete" connection="amqp" handler="Magento\Queue\Model\ProductDeleteConsumer::processMessage" maxMessages="200" maxIdleTime="180" sleep="60" onlySpawnWhenMessageAvailable="0"/>
<consumer name="rpc.test" queue="queue.for.rpc.test.unused.queue" consumerInstance="Magento\Framework\MessageQueue\BatchConsumer"/>
<consumer name="test.product.delete" queue="queue.for.test.product.delete" handler="Magento\Queue\Model\ProductDeleteConsumer::processMessage" maxMessages="200" maxIdleTime="180" sleep="60" onlySpawnWhenMessageAvailable="0"/>
</config>
```

Expand All @@ -94,7 +94,7 @@ The `queue_consumer.xml` file contains one or more `consumer` elements:
| queue (required) | Defines the queue name to send the message to. |
| handler | Specifies the class and method that processes the message. The value must be specified in the format `<Vendor>\Module\<ServiceName>::<methodName>`.|
| consumerInstance | The class name that consumes the message. Default value: `Magento\Framework\MessageQueue\Consumer`. |
| connection | Connection is defined dynamically based on deployment configuration of message queue in `env.php`. If AMQP is configured in deployment configuration, AMQP connection is used. Otherwise, db connection is used. If you still want to specify connection type for consumer, keep in mind that for AMQP connections, the connection name must match the `connection` attribute in the `queue_topology.xml` file. Otherwise, the connection name must be `db`. |
| connection | Connection is defined dynamically based on deployment configuration of message queue in `env.php`. If AMQP or STOMP is configured in deployment configuration, the respective connection is used. Otherwise, db connection is used. If you still want to specify connection type for consumer, keep in mind that for AMQP connections, the connection name must match the `connection` attribute in the `queue_topology.xml` file. For STOMP connections, use `stomp`. Otherwise, the connection name must be `db`. |
| maxMessages | Specifies the maximum number of messages to consume.|
| maxIdleTime | Defines the maximum waiting time in seconds for a new message from the queue. If no message was handled within this period of time, the consumer exits. Default value: `null`|
| sleep | Specifies time in seconds to sleep before checking if a new message is available in the queue. Default value is `null` which equals to 1 second.|
Expand Down Expand Up @@ -178,7 +178,7 @@ The `queue_topology.xml` file defines the message routing rules and declares que
| -------------- | ----------- |
name (required) | A unique ID for the exchange.
type | Specifies the type of exchange. The default value is `topic` because only `topic` type is supported.
connection (required) | Connection is defined dynamically based on deployment configuration of message queue in `env.php`. If AMQP is configured in deployment configuration, AMQP connection is used. Otherwise, db connection is used. If you still want to specify connection, the connection name must be `amqp` for AMQP. For MySQL connections, the connection name must be `db`.
connection (required) | Connection is defined dynamically based on deployment configuration of message queue in `env.php`. If AMQP or STOMP is configured in deployment configuration, the respective connection is used. Otherwise, db connection is used. If you still want to specify connection, the connection name must be `amqp` for AMQP, `stomp` for STOMP. For MySQL connections, the connection name must be `db`.
durable | Boolean value indicating whether the exchange is persistent. Non-durable exchanges are purged when the server restarts. The default is `true`.
autoDelete | Boolean value indicating whether the exchange is deleted when all queues have finished using it. The default is `false`.
internal | Boolean value. If set to true, the exchange may not be used directly by publishers, but only when bound to other exchanges. The default is `false`.
Expand Down Expand Up @@ -233,6 +233,8 @@ The `queue_publisher.xml` file defines which connection and exchange to use to p

### Example

__For RabbitMQ (AMQP):__

```xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework-message-queue:etc/publisher.xsd">
Expand All @@ -244,27 +246,47 @@ The `queue_publisher.xml` file defines which connection and exchange to use to p
</config>
```

__For ActiveMQ Artemis (STOMP):__

```xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework-message-queue:etc/publisher.xsd">
<publisher topic="magento.testModuleSynchronousAmqp.api.serviceInterface.execute" disabled="true" />
<publisher topic="asynchronous.test" queue="async.test.queue">
<connection name="stomp" disabled="false"/>
<connection name="db" disabled="true"/>
</publisher>
</config>
```

#### `publisher` element

| Attribute | Description |
| -------------------- | ----------- |
| topic (required) | The name of the topic. |
| queue | For ActiveMQ Artemis (STOMP), specify the queue name when it differs from the topic name. |
| disabled | Determines whether this queue is disabled. The default value is `false`. |

#### `connection` element

The `connection` element is a subnode of the `publisher` element. There must not be more than one enabled active connection to a publisher defined at a time. If you omit the `connection` element, connection will be defined dynamically based on deployment configuration of message queue in `env.php` and exchange `magento` will be used. If AMQP is configured in deployment configuration, AMQP connection is used. Otherwise, db connection is used.
The `connection` element is a subnode of the `publisher` element. There must not be more than one enabled active connection to a publisher defined at a time. If you omit the `connection` element, connection will be defined dynamically based on deployment configuration of message queue in `env.php` and exchange `magento` will be used. If AMQP or STOMP is configured in deployment configuration, the respective connection is used. Otherwise, db connection is used.

| Attribute | Description |
| -------------------- | ----------- |
| name | Connection name is defined dynamically based on deployment configuration of message queue in `env.php`. If you still want to specify connection type for publisher, keep in mind that for AMQP connections, the connection name must match the `connection` attribute in the `queue_topology.xml` file. Otherwise, the connection name must be `db`. |
| name | Connection name is defined dynamically based on deployment configuration of message queue in `env.php`. If you still want to specify connection type for publisher, keep in mind that for AMQP connections, the connection name must match the `connection` attribute in the `queue_topology.xml` file. For STOMP connections, use `stomp`. Otherwise, the connection name must be `db`. |
| exchange | The name of the exchange to publish to. The default system exchange name is `magento`. |
| disabled | Determines whether this queue is disabled. The default value is `false`. |

<InlineAlert variant="warning" slots="text"/>

You cannot enable more than one `publisher` for each `topic`.

## ActiveMQ Artemis (STOMP) Support

<InlineAlert variant="info" slots="text"/>

ActiveMQ Artemis (STOMP) support was introduced in Adobe Commerce 2.4.6 and later versions. For STOMP connections, use ANYCAST addressing mode for point-to-point message delivery and load balancing across multiple consumers.

## Updating `queue.xml`

See [Migrate message queue configuration](migration.md) for information about upgrading from Adobe Commerce and Magento Open Source 2.0 or 2.1.
Loading