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

New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New
marius95
Hello everyone, I try to use an Javascript Event Handler in my root.html.leex file. Therefore I created a function in the app.js file: ...
New
JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New

Other popular topics Top

rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
nobody
Hi! In PHP: $_SERVER[‘SERVER_ADDR’] - in Elixir? Searched the docs for ip address and the web, no good results. Thanks!
New
JeremM34
Hello, how can I check the Phoenix version ? Thanks !
New
vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
AngeloChecked
What learn first? Rust or Elixir Hi Elixir community! I’m here because i want learn a new language. I’m a junior developer and mainly i ...
New

We're in Beta

About us Mission Statement