Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions design-documents/asynchronous-operations/poison-pill.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
## Glossary

poison pill
: message that added after list of events in Data Storage that signals that consumer should die.

### Overview

Right now our consumer depends on config/objects in-memory state. After application was bootstrapped it initialize a lot of object that are always kept in memory after first load - config, websites, etc.., since our consumers are long-living and their live time limited only by message count it could happens that our consumer keep outdated im-memory config/objects states. Considering that, we need to introduce the way to reinit them.

### Design

Basic implementation of how the pill will be added should be implemented inside Magento Framework. We will share the api that let each module call whenever it needed.

Api Interface - *PoisonPillInterface* will be inside Magento Framework, implementation in MessageQueue module.

PoisonPillInterface
```php
/**
* Put poison pill inside DB.
*
* @throws \Exception
* @return int
*/
public function put();
```

Before process new message, consumer will compare version of PoisonPill in-memory state with latest in DB. If version is different consumer dies and next cron:run will start new instance of consumer.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it mean that there will be at least one MySQL DB query for each consumed message?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add warning to the design document for the team implementing this feature to verify performance implications.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@paliarush @vzabaznov I am concerned about this point specifically, if for each read we are hitting the database query, then what is the purpose of storing configurations in-memory? we might lose the benefits of in-memory optimizations. We should think differently here, on invalidating the cache on event based.


#### Acceptance Criteria Fulfillment

1. If consumer takes message to process after poison pill was placed, consumer must be reinited.

#### Extension Points and Scenarios

We will put poison pill into Data Storage based on common Magento extension points.