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
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
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 ![]()
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #hex
- #security










