diff --git a/lib/pgboss.service.ts b/lib/pgboss.service.ts index a382e54..0ab3e15 100644 --- a/lib/pgboss.service.ts +++ b/lib/pgboss.service.ts @@ -21,7 +21,7 @@ export class PgBossService { data: TData, options?: PgBoss.SendOptions, ) { - await this.ensureQueueExists(name); + await this.pgBoss.createQueue(name); await this.pgBoss.send(name, data, options); } @@ -31,7 +31,7 @@ export class PgBossService { data?: TData, options?: PgBoss.ScheduleOptions, ) { - await this.ensureQueueExists(name); + await this.pgBoss.createQueue(name); await this.pgBoss.schedule(name, cron, data ?? {}, options ?? {}); } @@ -42,7 +42,7 @@ export class PgBossService { data?: TData, options?: PgBoss.ScheduleOptions, ) { - await this.ensureQueueExists(name); + await this.pgBoss.createQueue(name); await this.pgBoss.schedule(name, cron, data ?? {}, options ?? {}); await this.pgBoss.work( name, @@ -56,18 +56,11 @@ export class PgBossService { handler: WorkWithMetadataHandler, options?: PgBoss.WorkOptions, ) { - await this.ensureQueueExists(name); + await this.pgBoss.createQueue(name); await this.pgBoss.work( name, { ...options, includeMetadata: true }, handler, ); } - - async ensureQueueExists(queueName: string) { - const currentQueue = await this.pgBoss.getQueue(queueName); - if (!currentQueue) { - await this.pgBoss.createQueue(queueName); - } - } }