System design hack: Postgres is a great pub/sub & job server

This is very interesting feature of Postgres I didn’t know about. Is anyone using it?

4 Likes

I think that’s what Oban uses, and yes, it’s great :slight_smile:

3 Likes

I actually didn’t get the part where or how you listen to those notifications from Postgresql in your Worker.
Do I do the listening part with Ecto?

Edit: This helped

2 Likes

oban is amazing…

for the simple listen/notify you can use boltun GitHub - bitgamma/boltun: Transforms notifications from the Postgres LISTEN/NOTIFY mechanism into callback execution

1 Like

just FYI: you can lost messages when you use LISTEN/NOTIFY feature of Postgresql. There is no buffer or queue, so when you lost connections for a few ms you don’t get message which was sent at that time.

5 Likes