Skip to content

Commit 4f1ed10

Browse files
authored
Grammar and formatting
1 parent 6683678 commit 4f1ed10

File tree

1 file changed

+55
-58
lines changed

1 file changed

+55
-58
lines changed

src/guides/v2.3/extension-dev-guide/message-queues/refresh-config.md

Lines changed: 55 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,18 @@ functional_areas:
66
- System
77
---
88

9-
When Magento is launched, the store's configuration is loaded and copied into memory. Magento uses that copy in memory for queue message transactions. When the store's configuration is updated in the admin, the copy in memory does not automatically refresh, resulting in an outdated in-memory object state.
9+
When Magento is launched, the store's configuration is loaded into memory. Magento uses the in-memory configuration for queue message transactions. When the store's configuration is updated in the admin, the copy in memory does not refresh automatically, resulting in an outdated in-memory object state.
1010

1111
To ensure the copy in memory is re-instantiated after an update, use the `PoisonPill` interfaces available in the MessageQueue module.
1212
There are three type of the `PoisonPill` interfaces:
13-
`Magento\Framework\MessageQueue\PoisonPill\PoisonPillPutInterface` - The interface contains the `put` method. The implementation of the method puts new version of poison pill inside DB.
14-
`Magento\Framework\MessageQueue\PoisonPill\PoisonPillReadInterface` - The interface contains the `getLatestVersion` method. The implementation of the method gets and returns get latest version of poison pill.
15-
`Magento\Framework\MessageQueue\PoisonPill\PoisonPillCompareInterface` - The interface contains the `isLatestVersion` method. The implementation of the method checks if version of current poison pill is latest.
1613

17-
Before a new message is processed, the implementation of the `PoisonPillCompareInterface` compares the version of the in-memory copy to the latest in the database. If the versions are different, the in-memory copy is destroyed and a new copy is created when the next `cron:run` job executes.
14+
*. `Magento\Framework\MessageQueue\PoisonPill\PoisonPillPutInterface` - The interface contains the `put` method. An implementation of the method puts a new version of poison pill inside the database.
15+
*. `Magento\Framework\MessageQueue\PoisonPill\PoisonPillReadInterface` - The interface contains the `getLatestVersion` method. An implementation of the method gets and returns get latest version of the poison pill.
16+
*. `Magento\Framework\MessageQueue\PoisonPill\PoisonPillCompareInterface` - The interface contains the `isLatestVersion` method. An implementation of the method checks if the version of current poison pill is the latest.
1817

19-
In addition to changes in the configuration, a new store view or a new website also trigger the `PoisonPill` interface.
18+
Before a new message is processed, the `PoisonPillCompareInterface` compares the version of the in-memory copy to the latest in the database. If the versions are different, the in-memory copy is destroyed and a new copy is created when the next `cron:run` job executes.
19+
20+
In addition to changes in the configuration, a new store view or a new website can also trigger the `PoisonPill` interface.
2021

2122
If `PoisonPill` determines the copy of the in-memory state needs to be re-instantiated and you have set up a `consumers_runner` cron job, Magento will automatically restart all consumers on the next run of the job. If you did not set up the cron job, you will need to manually restart any consumers that were terminated by `PoisonPill`.
2223

@@ -25,65 +26,61 @@ If `PoisonPill` determines the copy of the in-memory state needs to be re-instan
2526
The method `put` of `PoisonPillPutInterface` using in the `Magento\Store\Model\Website`
2627

2728
```php
28-
/**
29-
* Clear configuration cache after creation website
30-
*
31-
* @return $this
32-
* @since 100.2.0
33-
*/
34-
public function afterSave()
35-
{
36-
...
37-
38-
$this->pillPut->put();
39-
return parent::afterSave();
40-
}
29+
/**
30+
* Clear configuration cache after creation website
31+
* @return $this
32+
* @since 100.2.0
33+
*/
34+
public function afterSave()
35+
{
36+
...
37+
$this->pillPut->put();
38+
return parent::afterSave();
39+
}
4140
```
4241

43-
The method `getLatestVersion` of `PoisonPillReadInterface` using in the `Magento\Framework\MessageQueue\CallbackInvoker`
42+
The method `getLatestVersion` of `PoisonPillReadInterface` using in the `Magento\Framework\MessageQueue\CallbackInvoker`:
4443

4544
```php
46-
/**
47-
* Run short running process
48-
*
49-
* @param QueueInterface $queue
50-
* @param int $maxNumberOfMessages
51-
* @param \Closure $callback
52-
* @return void
53-
*/
54-
public function invoke(QueueInterface $queue, $maxNumberOfMessages, $callback)
55-
{
56-
$this->poisonPillVersion = $this->poisonPillRead->getLatestVersion();
57-
58-
...
59-
}
45+
/**
46+
* Run short running process
47+
* @param QueueInterface $queue
48+
* @param int $maxNumberOfMessages
49+
* @param \Closure $callback
50+
* @return void
51+
*/
52+
public function invoke(QueueInterface $queue, $maxNumberOfMessages, $callback)
53+
{
54+
$this->poisonPillVersion = $this->poisonPillRead->getLatestVersion();
55+
...
56+
}
6057
```
6158

62-
The method `isLatestVersion` of `PoisonPillCompareInterface` using in the `Magento\Framework\MessageQueue\CallbackInvoker`
59+
The method `isLatestVersion` of `PoisonPillCompareInterface` using in the `Magento\Framework\MessageQueue\CallbackInvoker`:
6360

6461
```php
65-
/**
66-
* Run short running process
67-
*
68-
* @param QueueInterface $queue
69-
* @param int $maxNumberOfMessages
70-
* @param \Closure $callback
71-
* @return void
72-
*/
73-
public function invoke(QueueInterface $queue, $maxNumberOfMessages, $callback)
74-
{
75-
$this->poisonPillVersion = $this->poisonPillRead->getLatestVersion();
76-
for ($i = $maxNumberOfMessages; $i > 0; $i--) {
77-
do {
78-
$message = $queue->dequeue();
79-
// phpcs:ignore Magento2.Functions.DiscouragedFunction
62+
/**
63+
* Run short running process
64+
*
65+
* @param QueueInterface $queue
66+
* @param int $maxNumberOfMessages
67+
* @param \Closure $callback
68+
* @return void
69+
*/
70+
public function invoke(QueueInterface $queue, $maxNumberOfMessages, $callback)
71+
{
72+
$this->poisonPillVersion = $this->poisonPillRead->getLatestVersion();
73+
for ($i = $maxNumberOfMessages; $i > 0; $i--) {
74+
do {
75+
$message = $queue->dequeue();
76+
// phpcs:ignore Magento2.Functions.DiscouragedFunction
8077
} while ($message === null && (sleep(1) === 0));
81-
if (false === $this->poisonPillCompare->isLatestVersion($this->poisonPillVersion)) {
82-
$queue->reject($message);
83-
// phpcs:ignore Magento2.Security.LanguageConstruct.ExitUsage
84-
exit(0);
85-
}
86-
$callback($message);
87-
}
88-
}
78+
if (false === $this->poisonPillCompare->isLatestVersion($this->poisonPillVersion)) {
79+
$queue->reject($message);
80+
// phpcs:ignore Magento2.Security.LanguageConstruct.ExitUsage
81+
exit(0);
82+
}
83+
$callback($message);
84+
}
85+
}
8986
```

0 commit comments

Comments
 (0)