timgit/pg-boss

Issues with queue in v10

stefanvanherwijnen opened this issue · 6 comments

Hi,

I noticed a few issues while trying to migrate to v10.

import PgBoss from "pg-boss";

const boss = new PgBoss('postgres://user:pass@host/database');

boss.on("error", console.error);

await boss.start();

const queue = "readme-queue";

console.log(await boss.getQueueSize(queue));
if (!(await boss.getQueueSize(queue))) {
  await boss.createQueue(queue);
}
const id = await boss.send(queue, { arg1: "read me" });
await boss.schedule(queue + ":test", "* * * * *", { data: "data" });
console.log(`created job ${id} in queue ${queue}`);

await boss.work(queue + ":*", async (job) => {
  console.log(`received job ${job.id} with data ${JSON.stringify(job.data)}`);
});

Firstly, createQueue() does not seem to be optional and not creating a queue before sending a job to it result in no running jobs at all.

Secondly, using a wildcard in a worker does not seem to work at all (the worker never runs).

Third, running deleteQueue(queue) doesn´t seem to delete the created table and will result in an error when createQueue(queue) is ran after it (error: relation "job_1cf8f2ada856014a7b8b7f085da16cd67a05144a5830a720f1a98755" already exists).

Creating queues is required starting in v10. Wildcards are also currently not supported. These changes are listed in the beta release notes.

Thanks. I know creating queues is required in v10, but the createQueue documentation states it is an optional step so I was confused. I also couldn't find anything about the wildcard support in the release notes.

I'll keep this open until v10 is released in case anyone else runs into the same problem.