Configure message queue topology
The message queue topology can only be configured after Magento Open Source has been installed and before Magento Commerce has been installed.
Each module that is to be a publisher must be configured as such. If you want a module to use the MQF, create a <module>/etc/queue.xml
file and define the publisher, consumers, exchanges and bindings.
Edit the queue.xml
file
The queue.xml
file can contain the following elements:
- publisher
- topic
- consumer
- bind
Required elements
Each queue.xml
file must contain the following lines:
publisher element
The publisher
element configures the type of connection and the exchange to publish to. By default, Magento uses one exchange. The name of exchange is a part of the publisher configuration. However multiple exchanges are supported, based on the AMQP model.
Parameter | Description |
---|---|
name | A unique identifer for the publisher. The value is specified in a topic element. The default system publisher name is `default`. |
connection | If RabbitMQ is to used to manage the queue, then the value must be rabbitmq . The value can also be db or the name of a custom adapter. |
exchange | The name of the exchange to publish to. The value is referenced from the bind element. The default system exchange name is `magento`. |
topic element
Configuring the topic
element defines the interface that processes the message and assigns a publisher.
Parameter | Description |
---|---|
name | The name assigned to the topic. The format should be Examples: The value is specified in a |
schema | The interface that describes the structure of the message. It should be in the format of a Data Interface from the Service Contracts. For example, You can also specify a service method signature, such as |
publisher | The name of a publisher . |
consumer element
Each consumer
elements maps the receiver of a message to a specific queue. The class
and method
parameters indicate what receives and processes the message.
Parameter | Description |
---|---|
name | The name of the consumer. The value should be the same as the magic method that to be used as a callback. |
queue | Defines the queue name to send the message to. This value is used in the definition of a bind element. |
connection | Must be rabbitmq or other value specified in the `connection` parameter in of a publisher. |
class | The path to a Magento class that consumes the message. |
method | The method within the specified class that processes the message. |
max_messages | Specifies the maximum number of messages to consume. |
bind element
The bind
elements link topics to queues and exchanges, defining the message queue topology. A topic can be sent to any number of queues.
Parameter | Description |
---|---|
queue | The name of a queue defined in a consumer element. |
exchange | The name of an exchange defined in a publisher element. |
topic | The name of a topic defined in a topic element. You can specify an asterisk (\*) or pound sign (#) as wildcards. |