prisma-queue icon indicating copy to clipboard operation
prisma-queue copied to clipboard

I want to use this but have no idea how to use with NextJS

Open salvinoto opened this issue 1 year ago • 3 comments

Do I have to run this as a separate process, or does it get initiated somewhere? The get started is a bit vague thanks for any help!

salvinoto avatar Dec 21 '24 16:12 salvinoto

Hey @salvinoto ,

We are running it as dedicated service.

The service uses pm2 to start our queues.

For recurring jobs, we start them after initializing the queue. Otherwise we use the enqueue method to add new jobs to the queue (e.g. via a server action in nextjs)

Does this help?

If you need more information about the implementation, please let me know.

Can provide an example on Monday (got no approval to work on this weekend from my wife 🤭)

noxify avatar Dec 21 '24 18:12 noxify

@noxify would love to see the example? The documentation is rather sparse here, for example, in the readme.md it says

import { emailQueue } from "./emailQueue";

const main = async () => {
  await queue.start();
};

main();

where is queue coming from? I am guessing it's a typo that it should have been emailQueue, if that is the case, is queue blocking? how to start multiple queues? Promise.all?

Would love some guidance 🙏🏻

hyusetiawan avatar Apr 02 '25 02:04 hyusetiawan

Hey @hyusetiawan ,

where is queue coming from? I am guessing it's a typo that it should have been emailQueue, if that is the case, is queue blocking?

It's a typo in the example. queue should be emailQueue.

how to start multiple queues? Promise.all?

To manage multiple queues, I decided to use pm2 to have a "standarized way" to manage my queues.

Here the link to the relevant code: https://github.com/noxify/prisma-queue-example

Maybe a bit over-engineered, but it works :D I'm not that good in explaining, but if you have any questions, please let me know.

noxify avatar Apr 02 '25 09:04 noxify