quazar
quazar

Reputation: 590

How to check state of exq job in phoenix framework?

I am using exq as background processing in phoenix framework. Is there a way to check state of exq jobs using job_id to know if it has been completed or failed or what? I went through documentation but there’s not much info about it.

Upvotes: 1

Views: 764

Answers (2)

quazar
quazar

Reputation: 590

Thank you @mudasobwa, I got it working here's complete example for someone whose wondering same.

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 on https://hexdocs.pm/exq/Exq.Api.html

Upvotes: 1

Aleksei Matiushkin
Aleksei Matiushkin

Reputation: 121010

Exq has Exq.Api that is documented. I would suggest you need Exq.Api.find_job/3.

Unfortunately, the documentation does not provide links to the source, so here it is.

Upvotes: 1

Related Questions