fix: Resume workflow execution (#7103)

Supercedes #7051 – if OK, I'll move the base of this PR to `develop` and we can run reviews only of this one.

**What**
- Gracefully close BullMQ Worker in Redis Event Bus and Redis Workflow Engine (by @edast, @sradevski)
- Register workflows before MedusaApp is loaded*
- Introduce `onApplicationPrepareShutdown`**
- Refactor plugin resolving for reusability purposes

*We now register workflows before modules are loaded to ensure modules can run workflows as part of bootstrapping. E.g. the Redis Workflow Engine resumes workflows when it starts, which has until this change failed, because the workflows were not registered yet.

**We introduce a new hook to prepare resources for an application shutdown. E.g. closing the BullMQ worker as a preparatory step to closing the BullMQ queue. The worker will continue to process jobs while the queue is still open to receive new jobs (without processing them). 

Co-authored-by: Stevche Radevski <4820812+sradevski@users.noreply.github.com>
Co-authored-by: Darius <618221+edast@users.noreply.github.com>
Co-authored-by: Carlos R. L. Rodrigues <37986729+carlos-r-l-rodrigues@users.noreply.github.com>
This commit is contained in:
authored and GitHub committed 2024-04-22 12:32:50 +00:00
1 parent 67a21c3e45
commit 0eb68541b8
24 files changed
+351 -228

No files matched your search

+4 -22
View File
@@ -9221,7 +9221,7 @@ __metadata:
"@mikro-orm/migrations": 5.9.7
"@mikro-orm/postgresql": 5.9.7
awilix: ^8.0.0
bullmq: ^5.1.3
bullmq: ^5.4.2
cross-env: ^5.2.1
dotenv: ^16.4.5
ioredis: ^5.3.2
@@ -22504,36 +22504,18 @@ __metadata:
languageName: node
linkType: hard
"bullmq@npm:^5.1.3":
version: 5.1.3
resolution: "bullmq@npm:5.1.3"
dependencies:
cron-parser: ^4.6.0
glob: ^8.0.3
ioredis: ^5.3.2
lodash: ^4.17.21
msgpackr: ^1.10.1
node-abort-controller: ^3.1.1
semver: ^7.5.4
tslib: ^2.0.0
uuid: ^9.0.0
checksum: dc2177dfd736b2d008ccab1ba9f77f80cc730ce6197c9ffa0f37327e1cf34bd8b97d83ee9f9008253ef0c0854bbd04f8c925889a3370a0899e8f5c7a34fd3ab3
languageName: node
linkType: hard
"bullmq@npm:^5.4.2":
version: 5.4.2
resolution: "bullmq@npm:5.4.2"
version: 5.7.3
resolution: "bullmq@npm:5.7.3"
dependencies:
cron-parser: ^4.6.0
ioredis: ^5.3.2
lodash: ^4.17.21
msgpackr: ^1.10.1
node-abort-controller: ^3.1.1
semver: ^7.5.4
tslib: ^2.0.0
uuid: ^9.0.0
checksum: 01687a41bbacb646ab9cac181181c0cf18362f23b250c332125e0a701dacefb48ff20b030e095f24bd5e471f29d514bcc02779fd1f1c3cb830a3a5f1d0a39d75
checksum: eade5853736a9ad606fe6f7b0d000585d7122ca3f5e4b71965cef448b77f3b8748f90ea420b90cf8e2fd7db737197946cc57ffbdb7ea8e8e4945875cc54b74d5
languageName: node
linkType: hard