logoalt Hacker News

simonwyesterday at 6:15 PM5 repliesview on HN

> Oban allows you to insert and process jobs using only your database. You can insert the job to send a confirmation email in the same database transaction where you create the user. If one thing fails, everything is rolled back.

This is such a key feature. Lots of people will tell you that you shouldn't use a relational database as a worker queue, but they inevitably miss out on how important transactions are for this - it's really useful to be able to say "queue this work if the transaction commits, don't queue it if it fails".

Brandur Leach wrote a fantastic piece on this a few years ago: https://brandur.org/job-drain - describing how, even if you have a separate queue system, you should still feed it by logging queue tasks to a temporary database table that can be updated as part of those transactions.


Replies

zieyesterday at 9:52 PM

I agree this is an awesome feature. I use pg_timetable instead of Oban though: https://cybertec-postgresql.github.io/pg_timetable/v6.x/

nhumrichyesterday at 7:26 PM

This is called the "transactional outbox pattern"!

show 1 reply
elflyyesterday at 11:18 PM

Lots of people are also trying to just use postgres for everything, tho.

airockeryesterday at 11:01 PM

Debezium was built exactly for that to power a queue based on WAL.

sieepyesterday at 8:39 PM

Excellent point. Never thought of transactions in this way.