Need Help Building Simple Database Persistence: GenStage & Broadway?

I did read the GenServer docs and a lot of that made sense. @cmkarlsson actually provided an excellent example that was similar to what I was looking for, and really helped with learning GenServer: Questions about saving chat messages to database. Failed inserts? Spawning? More Efficient Way? - #2 by cmkarlsson . However, he explained that the GenServer stops receiving new messages while it saves current message to the database, and it didn’t provide back pressure, inserting in batches to prevent overloading database, or a way to handle database downtime (retry inserts later). The example was pretty darn close to what I needed.

After studying the GenServer docs and reading more, I discovered GenStage might be a better way to do this, and that Broadway might be the way to handle database downtime / failed inserts.

I’ll read the AMQP guide that you provided and see if I can get more insights. Also for reference, I found a great guide for installing RabbitMQ on Ubuntu 20.04 and getting it up and running: https://computingforgeeks.com/how-to-install-latest-rabbitmq-server-on-ubuntu-linux/ , no unexpected install problems.

1 Like