adammokan

adammokan

I’ve used the after_process/3 callback a number of times when implementing a Oban.Pro.Worker and it tends to work great for handling any cleanup or updating something in the database based on the job status.

I have a situation today where I’m implementing a Oban.Pro.Workers.Workflow with up to 3 dynamic child stages appended during execution and I realized I want to have a final callback that allows me to update a supporting record in the DB when the entire workflow completes. Reached for the after_process callback and instinctively added that to my first workflow stage, but (logically in hindsight) it fires right when that first stage completes rather than the entire workflow itself.

My primary question here is if I am missing something on how to handle this via a callback when using workflows? Or is the answer to append that final step I hoped to handle in the callback as a child of the workflow as its own job or is it recommended to attach that callback to the final stage of my workflow?

I think what makes this a bit confusing is that we do have a workflow-centric callback in the form of after_cancelled/4. So it seems like we should have some way to do the same for workflows that were not cancelled?

Appreciate any insight on this!

Update: I did just realize after_cancelled/4 is brand new as of last week. So maybe a similar approach for success cases is in the works :person_shrugging:

Showing Posts 1 to 1

sorentwo

sorentwo

Oban Core Team

You’re not missing anything—appending a final job as the last step or adding an after_process/3 callback to the final job in the workflow is the way to solve this. I’d suggest a final job over a callback because you’ll have all the niceties of a job (i.e. retries), and it’s more obvious if you look at the workflow as a whole.

That callback is brand new (as noted in your update), and it was added to handle a situation that was impossible before. Prior to after_cancelled/2, there wasn’t any way to react to downstream workflow jobs getting cancelled because they weren’t actually running.

This use-case comes up frequently and a first-class approach for “batch callback” functionality in workflows is in the works :slightly_smiling_face:

— All posts loaded —

Where Next? Top

Trending in Questions Top

katta
I having some trouble figuring out if I have set myself too strict of standards for my production server. Currently I can handle 75% of r...
New
achenet
Hello, I’m trying to build a basic Phoenix web-app, and I’d like to use Tailwind. However, when I launch mix phx.server, I get an error...
New
bradley
I really like the adapter patterns that ecto, nebulex, waffle, etc. use and would love find something similar for a key management servic...
New
Cxx-mlr
I’m working on a small exercise involving update_in/3, and I came up with this solution: data = %{ name: "Periodic Table", category:...
New
unaware8150
Hello folks! So at work, we are seeing some situations where we have to define some “fixed” strings that are used across the codebase in...
New
ChrisAmelia
I’ve got trouble wrapping my head around the order in which functions are called in this snippet (from Phoenix’s authentication): toke...
New
dillonoconnor
Is there any way to avoid the Hologram compiler running when using iex? It seems like the front-end code could potentially be disregarded...
New

Other Trending Topics Top

GenericJam
Edit: 2026 May 15 - This post is archived. Mob is alive!! Main docs: mob v0.7.11 — Documentation A bit of explanation for the slightly c...
New
garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
budgie
A little off-topic, but I feel like people here have a good head on their shoulders. I used to be quite good at making software. Was luc...
New
KristerV
Hey. Is there anyone here who creates agents in their apps? Not talking about using agents, but creating them. I’m finding it pretty diff...
New
mcass19
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
juhalehtonen
There has been a thread to discuss the Stack Overflow Developer Survey on this forum every year since 2018, so here’s yet another one for...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews