jdellitt

jdellitt

Pause Oban Pro Workflow?

Is it possible to pause a Workflow then continue it at a later time? For example, we’d like to start a Workflow with several Jobs, but want to put it into a suspended/paused state until some external event occurs (like a webhook), which would satisfy the dependency and resume the rest of the workflow. Been looking through the docs, and haven’t seen anything, so just wanting to rule out whether or not it’s possible. Thanks!

First Post!

cevado

cevado

Doesn’t appeding jobs to a workflow solve your issue?

You can create a workflow with all the jobs that doesn’t rely on the webhook.
When the webhook happens, you can append the jobs that depend on the webhook and include their dependency on other jobs.
This way you never need to worry about the “state” of the jobs in that workflow, Oban takes care of the dependencies after you append the new jobs.

Last Post!

sorentwo

sorentwo

Oban Core Team

As alluded earlier in this thread, the way we usually suggest doing this is to have the job you’d like to pause snooze itself in a loop, with a limit to prevent unbounded retries. Here’s an example:

defmodule MyApp.PausedWorker do
  use Oban.Pro.Worker

  @impl Oban.Pro.Worker
  def process(job) do
    if some_external_event(job.args) do
      # do something here
    else
      {:snooze, 60}
    end
  end
end

You can optionally use unique and replace to upsert the snoozing job to run immediately, but it requires carefully setting the workflow_id:

  use Oban.Pro.Worker,
    unique: [meta: [:workflow_id, :name]],
    replace: [scheduled: [:scheduled_at]]

This question comes up rather frequently though, and a proper Oban.Pro.Workflow.pause/1 and Oban.Pro.Workflow.resume/1 seem warranted :thinking:

Where Next?

Popular in Questions Top

joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
New
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers’ Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
New
Lily
In templates/appointment/index.html.eex: <%= for appointment <- @appointments do %> <tr> <td><%= appoi...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New

Other popular topics Top

minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New
dogweather
I wrote this comment on r/haskell, and it’s not popular there. :wink: But I think I’m on to something… Haskell reminds me of Java, and e...
New
sen
Hi All, I set a environment variables in dev.exs , like below code. when i start server, how can i set the ${enable} value? thanks. d...
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New

We're in Beta

About us Mission Statement