# Pause Oban Pro Workflow?

**URL:** <https://forum.elixirforum.com/t/pause-oban-pro-workflow/63109>\
**Category:** Questions\
**Tags:** oban, oban-pro\
**Created:** [April 24, 2024, 10:03pm UTC](https://forum.elixirforum.com/t/pause-oban-pro-workflow/63109 "2024-04-24T22:03:18Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![jdellitt](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/jdellitt/32/31588_2.png) [@jdellitt](https://forum.elixirforum.com/u/jdellitt)\
**Post date:** [April 24, 2024, 10:03pm UTC](https://forum.elixirforum.com/t/pause-oban-pro-workflow/63109/1 "2024-04-24T22:03:18Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![cevado](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/cevado/32/40655_2.png) [@cevado](https://forum.elixirforum.com/u/cevado)\
**Post date:** [April 24, 2024, 11:41pm UTC](https://forum.elixirforum.com/t/pause-oban-pro-workflow/63109/2 "2024-04-24T23:41:36Z")

</div>

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

> **[Oban.Pro.Workers.Workflow — Oban Pro v1.4.5](https://oban.pro/docs/pro/1.4.5/Oban.Pro.Workers.Workflow.html)**

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.

---

<div class="post-metadata">

**Author:** ![jdellitt](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/jdellitt/32/31588_2.png) [@jdellitt](https://forum.elixirforum.com/u/jdellitt)\
**Post date:** [April 25, 2024, 4:02pm UTC](https://forum.elixirforum.com/t/pause-oban-pro-workflow/63109/3 "2024-04-25T16:02:57Z")

</div>

Thanks @cevado, I do think that could work, but I was hoping to be able to define the whole Workflow up front (in a single place) as opposed to having that logic in two different places.

It seems like we may need to have a job in the middle that essentially checks for a condition and snoozes itself itself if that condition hasn’t been fulfilled.

---

<div class="post-metadata">

**Author:** ![cevado](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/cevado/32/40655_2.png) [@cevado](https://forum.elixirforum.com/u/cevado)\
**Post date:** [April 25, 2024, 10:16pm UTC](https://forum.elixirforum.com/t/pause-oban-pro-workflow/63109/4 "2024-04-25T22:16:11Z")

</div>

> [@jdellitt](#):
>
> Thanks @cevado, I do think that could work, but I was hoping to be able to define the whole Workflow up front (in a single place) as opposed to having that logic in two different places.

you can make the code that append the jobs as a public function in the workflow module. this way you keep all the data about the workflow in the workflow module without needing to create a job that starves the queue/workers without a good reason.  
you could even use the meta option of a job to add some internal identifiers that makes it easier to find the workflow when the webhook happens.

---

<div class="post-metadata">

**Author:** ![bkilshaw](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/bkilshaw/32/30439_2.png) [@bkilshaw](https://forum.elixirforum.com/u/bkilshaw)\
**Post date:** [September 4, 2024, 6:32pm UTC](https://forum.elixirforum.com/t/pause-oban-pro-workflow/63109/5 "2024-09-04T18:32:42Z")

</div>

@jdellitt Did you ever figure this out by any chance?

---

<div class="post-metadata">

**Author:** ![jdellitt](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/jdellitt/32/31588_2.png) [@jdellitt](https://forum.elixirforum.com/u/jdellitt)\
**Post date:** [September 4, 2024, 7:46pm UTC](https://forum.elixirforum.com/t/pause-oban-pro-workflow/63109/6 "2024-09-04T19:46:36Z")

</div>

No, unfortunately. I think we ended up going in a different direction altogether.

---

<div class="post-metadata">

**Author:** ![sorentwo](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/sorentwo/32/37360_2.png) [@sorentwo](https://forum.elixirforum.com/u/sorentwo)\
**Post date:** [September 4, 2024, 8:09pm UTC](https://forum.elixirforum.com/t/pause-oban-pro-workflow/63109/7 "2024-09-04T20:09:18Z")

</div>

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:

```elixir
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`:

```elixir
  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 🤔
