How to check state of exq job?

Is there a way to check state of exq jobs using job_id? I went through documentation but there’s not much info about it.

From a quick look at the library, there is this handler:

handle_call({:find_job, queue, jid}, _from, state)

in Exq.Api.Server. So you should be able to do something like:

Exq.Api.Server.server_name(name_given_in_opts)    
|> send({:find_job, queue, job_id})

Haven’t tried, as this is just a look through the sources, but hopefully that sets you off on the right direction. (Also: looks like this will not work on an enqueuer node as that does not start an Api.server; all other node modes do though)

1 Like

Thanks that worked. Here’s complete example

job_pid = Application.get_env(:exq, :name) |> Exq.Api.Server.server_name
job_id = "935440ba-44c7-47d6-a973-2e23860dc54c"
{:ok, queued_for_retry_job} =  Exq.Api.find_retry(job_pid, job_id)

Exq.Api.find_failed(job_pid, job_id)
Exq.Api.find_jobs(job_pid, "queue" ,job_id)

All exq api function can be found here

2 Likes