MessageQueue Configuration in OroCloud
Message queues enable asynchronous processing of Oro application data. This means that the application is able to process data in the background without affecting user experience. Here are some examples of the message queue processing used in OroCommerce:
- import/export operations
- data audit
- integration with external systems (e.g., ERP)
- image resize
Your customized application can use message processing for many other reasons, and exact details depend on the implementation.
Message processing operates with the following entities:
- Message – the minimal piece of data processed by a consumer. Consists of the topic and the body. Message topic is used by the message processor to decide how to process a message and the message body consists of data that must be processed.
- Message Queue – the queue that holds messages until they are processed. Oro uses FIFO queue which means that the oldest messages are processed first while the newest must wait until older messages are processed and leave the queue.
- Consumer – a component which takes messages from the queue and process it one by one. Consumer processes one message at a time. It creates a specific processing job depending on the message topic.
OroCommerce uses RabbitMQ as a message broker which is a server responsible for managing message queues and transferring messages to the consumers. In OroCloud, consumers are hosted at the dedicated job servers and each message queue is processed by 4 consumers at each job server in order to provide high availability.
Default Configuration and Optimization
While it is possible to use many Oro application is configured to run 4 default message queues:
The production configuration may require more than 4 queues and the exact solution depends on the nature of your messages and details of implementation.
As it was mentioned above, message queue processes messages one at a time so some messages can require longer processing which means that other messages could stay in the queue for too long. Long processing time can be caused by:
- reindexing operations caused by mass import
- image resizing
- slow response from the external systems like ERP, email servers, etc.
- data audit requests can take considerable time to complete
Adding extra queues can help fix issues caused by slow message processing. Messages can be sorted to the different queues using their topic string. A single queue can contain messages with topics matching one or more routing keys.
There are 2 main strategies when adding extra queues to the Oro application:
- Move slow messages to the dedicated queue so these messages do not interfere with others.
- Move high priority messages to the dedicated queue so these messages do not wait for other messages with lower priority to be processed.
The exact configuration of the queues depends on the nature and the number of messages processed by the application. The number of queues is limited by the capacity of job servers since addition of one queue causes the addition of four consumers and increases the CPU and RAM utilization.
MQ Configuration Update
RabbitMQ is configured by OroCloud support which means that queue reconfiguration is done by submitting a ticket to the OroCloud Service Desk Portal. This ticket must provide clear information about the requested reconfiguration:
- The routing key strings.
- The target queue name for each routing key.
- Whether this is a new or an existing queue.
Please take into account that queue reconfiguration needs message queue restart, which means that all existing messages in the queues will be lost the moment the queue is restarted. In addition, the new queue configuration can affect the overall system performance. That is why Oro recommends testing the new configuration at the stage environment, and performs production reconfiguration after the customer approval and outside of the business time of the application.
Default Topic Mapping
Below is the topic mapping for default queues configuration.
oro.indexqueue manages topics:
oro.integrationqueue manages topics:
oro.systemqueue manages topics:
oro.defaultmanages all other topics.