QuestionQ66

VerifiedAdobe Commerce Architecture and Customization Techniques

A message queue currently has queue/consumer-wait -for-messages set to true, allowing the consumer process to run until a message is added to the queue. A functionality is driven by data stored in the model \Magento\Variable\Model\Variable, and this value is loaded only once during the consumer run. If the variable is updated, the consumer must restart so the new value is loaded into memory without reloading the variable for every consumed message.

The Adobe Commerce developer has created an after plugin on the \Magento\Variable\Model\Variable::save() function. How should the developer use the plugin to trigger the consumer restart?

Explanation

Magento\Framework\MessageQueue\PoisonPill\PoisonPillPutInterface::put() places the poison-pill restart signal that message-queue consumers check. A consumer that detects the signal terminates at its next status check and can be restarted by its process manager, causing startup-loaded configuration or model data to be read again. Adobe Commerce documents queue:consumers:restart as placing a poison pill to force consumers to restart after their next status check.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!