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:
authored and GitHub committed 2025-01-09 14:32:15 +01:00
1 parent 635d026f7f
commit 6747a1564b
2 files changed
+5

No files matched your search

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