Async Events API - check jobs

Hi there,

is there a way to check if the queue is empty or if it is still processing some jobs?
My use case is that one queue trigger another one and etc, but i need to identify when app is done with synchronization or when there is no more async events to process. What would be the best way to handle this?

Thank you

Hey Jan

Had a chat with the team. Turns out getStats() is exactly what you want here.

Hey @JoshuaHwang ,

yes I did see this function, but that mean I will need to keep track of all jobs and checking there statuses?

I was more looking for something what can tell if queue is empty or not.

Thank you

Ahh right,

It’s not possible to measure the number of jobs. You’ll need to store these jobs in something like the Storage API.
I’d recommend checking all the Storage API rows that start with job#... then run through each job to check the status of each. If it’s complete delete the corresponding rows.

Providing the number of jobs is unstable currently and would need deeper discussion whether we can commit to something like that in future.

1 Like

I see, Yes I was thinking to storing jobs in Storage API.

Thank you @JoshuaHwang for help!