Tech decision: Which queue service?

Right now I'm using NextJS with tRPC and want to send an email if someone replies to a post. But I don't want to block the tRPC query with sending an email. I thought a queue would be right thing to do. But which queue service would you think is the best for my setup?
19 Replies
chip
chipβ€’5mo ago
How much traffic do you have? How many users? Is this maybe just a pre-mature optimization? You could just send the email within the same function that handles the reply and don't bother with a queue until it actually becomes a noticable problem If you however want to, you have azure service bus/storage queue, cloudflare queues or something like uhhh BullMQ
clearlyunwell
clearlyunwellβ€’4mo ago
or AWS SQS, but agree on not using queues until it's a noticeable bottleneck to send immediately.
FleetAdmiralJakob πŸ—• πŸ—— πŸ—™
@Clearlyunwell @chip The problem is that I have the query and on finish of the query the page gets revalidated and the user sees his post/comment if I would add the email to the query the user would see his post way later.
clearlyunwell
clearlyunwellβ€’4mo ago
I see. So you want to fire and forget the email so you can get back to the user quicker. In this case queues would solve the problem. So would a database entry with the email data. Any mechanism to offload the actual sending of the email. But you’re asking which queuing service is recommended - I think that’s been answered πŸ™‚
Mocha
Mochaβ€’4mo ago
Sorry for the unrelated question. I’m just curious about how you’re triggering the revalidation from tRPC? I couldn’t figure out a smooth way to trigger it from a useMutation
sandulat
sandulatβ€’4mo ago
@FleetAdmiralJakob πŸ—• πŸ—— πŸ—™ There is also https://www.inngest.com/. Perhaps the simplest if deploying the app to Vercel.
Inngest - Build reliable products - Durable workflow engine
Easily develop serverless workflows in your current codebase, without any new infrastructure. Using Inngest, your entire team can ship reliable products.
FleetAdmiralJakob πŸ—• πŸ—— πŸ—™
I triggered it inside a server action I will try this one out, since it seems very easy to use
sandulat
sandulatβ€’4mo ago
Yeah and it's free for up to 50.000 jobs/month.
peterp
peterpβ€’4mo ago
Can only recommend Inngest
Mocha
Mochaβ€’4mo ago
Oh ok, are you able to get tRPC context (auth) in the server action too? Because I guess it's available in the middleware anyway
FleetAdmiralJakob πŸ—• πŸ—— πŸ—™
tRPC Middleware works as expected
FleetAdmiralJakob πŸ—• πŸ—— πŸ—™
GitHub
GitHub - FleetAdmiralJakob/postparrot: A nice little twitter clone
A nice little twitter clone. Contribute to FleetAdmiralJakob/postparrot development by creating an account on GitHub.
GitHub
GitHub - t3dotgg/server-actions-trpc-examples
Contribute to t3dotgg/server-actions-trpc-examples development by creating an account on GitHub.
Mocha
Mochaβ€’4mo ago
Thanks a lot! Much simpler than I expected
FleetAdmiralJakob πŸ—• πŸ—— πŸ—™
@peterp @sandulat Hi, I wanted to start building this email feature but now I'm wondering which is better suited for my usecase the background jobs or the queues. Do you have any insights or tips?
peterp
peterpβ€’4mo ago
If you want to send an email then just use Resend
peterp
peterpβ€’4mo ago
dawg?
Mocha
Mochaβ€’4mo ago
Can’t you just move the email logic to an API endpoint that you call without awaiting? This way the request is triggered, and since the API endpoint is the handler, even if you don’t await the result and just void sendEmail() it will still continue handling the request
Want results from more Discord servers?
Add your server
More Posts
Auth.js v5 issue with UntrustedHostHi all, I have hard times figuring out this issue. I am working on a Next.js 14 + Auth.js v5 projecPrisma queries return type anyI have a basic T3 app with Prisma that I just created today. Basic queries are giving a return type Compressing images before uploading to UploadThing?Is there a way we can intercept the incoming upload request and, if they are images, compress them bI am trying to add some developers emails and it is not letting meI am trying to add some of my developers by email and when I do it does not add their email to the eFinance industry compliance (SOC / WORM)Hey all, I'm semi new so I hope it's ok to ask here, but I am a freelancer I recently got approach wwhat should be the best go-to main portfolio fullstack project stack before looking for a job rn?Hi, here's my github profile, with the stack I know on a junior-mid level: https://github.com/WisieGoogle security error on next auth js redirecthey guys, I'm getting a dangerous site error when using next auth js's signing page flow. Has anyoneCode runner using AWS lambda functionHi guys, i want to build code runner using AWS lambda function with custom runtime images for each lShadcn Date Picker dropdown background color ?I have a problem with shadcn's Date picker component - in project that I'm currently building in cusIs it possible to create a component named Home in a NextJS project?As the title states, I've been messing around with this one page I ported over from v0 and named the