I’m not sure I understand exactly, but
I’m not sure I understand exactly, but can you call your function unconditionally from your queue() handler to do this?
11 Replies
I need to create 2 queues: 1 for calling an API that is rate limited and other for general file conversion. I want 1 queue to be slow and the other as fast as possible. This means that the queue consumer are different functions and in a team enviroment we would appreciate being able to associate a consumer function with a queue
I’m assuming you want to have one queue() handler for both these queues? Every message has a queue ID in there, maybe you can look at it to call your separate functions?
1 handler per queue
Hm, I feel like I’m missing something, can you then not call your separate functions from your separate queue() handlers?
Maybe some dummy code would help
There is no mention in the docs about multiple handlers, only 1 global handler where I can distinguish the queue based on the MessageBatch
Even if I declared more than 1 handler, it is not transparent which one would be or if both would execute. Associating a handler with a specific queue or a list of queues would make this a lot easier to understand
If you compare with AWS SQS, you can see on their docs that you can specific a queue for a consumer using the QueueUrl using their SDK, not HTTP pulling.
Sending and Receiving Messages in Amazon SQS - AWS SDK for JavaScript
JavaScript code example that applies to Node.js execution
Ah so I meant that if you have two queues, then you can have two Workers, each with a queue() handler. Worker A could be the fast queue and Worker B the slow one
If you’re using HTTP Pull, then the queue ID would be in the URL so I guess that matches SQS?
I'm not using HTTP pull, I'm using hono.js with wrangler, there is no documentation on how to assoaciate a queue with a queue handler
Is this what you’re looking for then? https://hono.dev/docs/getting-started/cloudflare-workers#using-hono-with-other-event-handlers
Cloudflare Workers - Hono
Web framework built on Web Standards for Cloudflare Workers, Fastly Compute, Deno, Bun, Vercel, Node.js, and others. Fast, but not only fast.
Hono is just an HTTP framework, it really has nothing to do with other kinds of handlers, but you can attach them this way ^
As mentioned before, I'm watch to associate a handlers with a single queue. Cloudflare documentation lacks any example on how to have 1 handler per queue, this is not a HonoJs issue.