pg-boss icon indicating copy to clipboard operation
pg-boss copied to clipboard

Peeking a job queue?

Open noamgat opened this issue 3 years ago • 1 comments

Hi, I'm using PGBoss in a setup that uses external job fulfillers, so I expose a REST API that includes things like getNextJob(queueName) and complete(jobId). I want to be able to build a monitoring solution on top of this. The monitor should be able to know that no worker has taken a job from a queue, by finding out that the next pending job on the AAA queue was created more than an hour ago. boss.getQueueSize() gives us the number of projects in the queue, but not how long ago it was created. fetch() gives me the job information, but also acts as a worker and removes the job from a pending state.

Is there a "peek" option (very common in queues) that allows me to get the information of the next job in a queue, without dequeuing it?

noamgat avatar Sep 01 '21 14:09 noamgat

There's not a peek() api in pg-boss, so you will need to build this yourself until it exists. Since pg-boss is also a priority queue, the fetch order isn't always creation date if you opt into creating higher priority jobs that can jump to the front of the queue. Keep that in mind if you decide to set this up via a custom SQL solution in the interim of this feature existing.

timgit avatar Sep 01 '21 19:09 timgit