fix: event-bus-redis processor execute event before subscriber are loaded (#10823)

* fix(worker): run worker after application start

* test(event-bus-redis): worker should initiate with autorun:false

---------

Co-authored-by: Suki Wang <suki.wang@shoplineapp.com>
Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>
This commit is contained in:
Sze-Chi Wang
2025-01-09 14:32:15 +01:00
committed by GitHub
parent 635d026f7f
commit 6747a1564b
2 changed files with 5 additions and 0 deletions

View File

@@ -63,6 +63,7 @@ describe("RedisEventBusService", () => {
{
connection: expect.any(Object),
prefix: "RedisEventBusService",
autorun: false
}
)
})

View File

@@ -68,12 +68,16 @@ export default class RedisEventBusService extends AbstractEventBusModuleService
prefix: `${this.constructor.name}`,
...(moduleOptions.workerOptions ?? {}),
connection: eventBusRedisConnection,
autorun: false,
}
)
}
}
__hooks = {
onApplicationStart: async () => {
await this.bullWorker_?.run()
},
onApplicationShutdown: async () => {
await this.queue_.close()
// eslint-disable-next-line max-len