Weitere ähnliche Inhalte
Ähnlich wie Using Magento 2.3 MySQL Queues (20)
Kürzlich hochgeladen (20)
Using Magento 2.3 MySQL Queues
- 2. © 2019 Magento, Inc.
.
Page | 2
Senior Software Developer at BORN Group
Renu Mishra
- 4. © 2019 Magento, Inc. Page | 4
Agenda
Need Of Queue
Introduction to Queues
Creating Queues with MySQL
Publishing messages to Queue
Consuming the published message
- 6. © 2019 Magento, Inc. Page | 6
Not In Scope
Parallel Consumer processing.
Batch Processing.
AMQP Implementation (RabbitMQ).
Advanced Error handling (Rejecting and Re-queuing).
Supervisiord for consumer monitoring.
- 8. © 2019 Magento, Inc. Page | 8
What is Queue and it’s uses ?
It distribute load across the application allowing work to placed in a
queue and process independently.
Received and processes the message asynchronously.
It also includes a mechanism for storing undelivered messages.
Queue works in background. It has no frontend user interaction.
- 11. © 2019 Magento, Inc. Page | 11
Queue Processing Description
A publisher is configured to send messages to a topic.
• A topic is a way to categorize messages to consumers.
• A consumer is configured to listen for messages with specific topics.
• Queues route topics to consumers.
• Consumers accept messages and perform actions on them.
- 20. © 2019 Magento, Inc. Page | 20
<module_root>/etc/publisher.xml
- publisher element
- topic : The name of the topic.Wildcards character are not supported.
- connection element
- name : For AMQP connections, the connection name must match the
connection attribute in the queue_topology.xml file. Otherwise,
the connection name must be db.
- exchange : The name of the exchange to publish to. The default
system exchange name is magento.
- 22. © 2019 Magento, Inc. Page | 22
<module_root>/etc/communication.xml
- topic element
- name : A string that uniquely identifies the topic.Wildcards character
are not supported in the communication.xml file(*,%,[] and so on).
- request : Specifies the data type of the topic.
- handler element
- name : A string that uniquely defines the handler.
- type : The class that defines the handler.
- method : The method this handler executes.
- 24. © 2019 Magento, Inc. Page | 24
Receive the Data From
Producer/Publisher
- 26. © 2019 Magento, Inc. Page | 26
<module_root>/etc/queue.xml
- broker element
- topic : A topic defined in the communication.xml file.
- exchange : The name of the exchange to publish to. The default
system exchange name is magento
- type : The type of message broker. For this release, the value
must be amqp or db.
- 27. © 2019 Magento, Inc. Page | 27
<module_root>/etc/queue.xml
- queue element
- name : Defines the queue name to send the message to.
- consumer : The name of the consumer.
- consumerInstance : The path to a Magento class that consumes the
message.
- handler : Specifies the class and method that processes the
message. The value must be specified in the format
<Vendor>Module<ServiceName>::<methodName>.
- 31. © 2019 Magento, Inc. Page | 31
<module_root>/etc/queue_topology.xml
- exchange element
- name : A unique ID for the exchange.
- type : Specifies the type of exchange. Must be topic.
- connection : For AMQP connections, a string that identifies the
connection. For MySQL connections, the connection
name must be db.
- 32. © 2019 Magento, Inc. Page | 32
<module_root>/etc/queue_topology.xml
- binding element
- id : A unique ID for this binding.
- topic : The name of a topic.
- destinationType : Must be queue.
- destination : Identifies the name of a queue.
- 36. © 2019 Magento, Inc. Page | 36
<module_root>/etc/queue_consumer.xml
- consumer element
- name : The name of the consumer.
- queue : 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 Magento class name that consumes the
message
- connection : For AMQP connections, the connection name must match
the connection attribute in the queue_topology.xml file.
Otherwise, the connection name must be db.
- 47. © 2019 Magento, Inc. Page | 47
MagentoFrameworkMessageQueuePu
blisherInterface
- 53. © 2019 Magento, Inc. Page | 53
Wait we need to run the
command before
executing the Queue
- 54. © 2019 Magento, Inc. Page | 54
Upgrade Command
Install the Queue Module
- 55. © 2019 Magento, Inc. Page | 55
What is happening in
background when
command executed ?
- 57. © 2019 Magento, Inc. Page | 57
Now Let’s Publish the
Queue using Controller
- 59. © 2019 Magento, Inc. Page | 59
What happen in
background when queue
published?
- 61. © 2019 Magento, Inc. Page | 61
It’s time to consume the
published message
- 62. © 2019 Magento, Inc. Page | 62
View a list of available
message queue
consumers
- 63. © 2019 Magento, Inc. Page | 63
View a list of available message queue
consumers
- 66. © 2019 Magento, Inc. Page | 66
What happen when
consumer start processing
?
- 69. © 2019 Magento, Inc. Page | 69
status column in queue_message_status
table
- 71. © 2019 Magento, Inc. Page | 71
MySQL Message Queue Setting
Stores > Settings > Configuration > Advanced > System > Cron
- 72. © 2019 Magento, Inc. Page | 72
Configure cron job consumer_runner in
app/etc/env.php
- 73. © 2019 Magento, Inc. Page | 73
cron_run - the option for enabling/disabling cron job consumers_runner, by
default is true.
max_messages - the maximum number of messages for each consumer
that must be processed before consumer terminate, by default is 1000. If it
is 0, then the consumer never stops working.
consumers - the list of consumers which will be run, by default is empty
array (all consumers are allowed to be run).
consumer_runner parameter Details