RabbitMQ with or without GenStage/Flow

I am beginning a proof of concept for an internal application to help promote Elixir. I would like to showcase the power and performance of the language platform. I have an existing messaging application using RabbitMQ. My thought were to build a publisher and consumer to connect with the existing implementation.

GenStage and Flow seem to provide value with this architecture pattern. However, as I am new to GenStage/Flow and RabbitMQ specifically, I am curious if introducing GenStage/Flow is redundant or an unnecessary abstraction.

Would you recommend using the Elixir capabilities on top of RabbitMQ? Or are the native features of RabbitMQ far superior to what could be demonstrated by GenStage/Flow?

Thanks for the advice.

2 Likes

I think that RabbitMQ is a good tool to manage back pressure, unless you have a very huge amount of data that needs to be handled really fast to the workers to not saturate RabbitMQ itself.
And also, rabbit workers, adopt a “push” pattern, so by adopting a back pressure system like GenStage, where you “pull” messages from rabbit, you are using it in a really strange way. There is already prefetch count and prefetch size from the amqp protocol that works pretty well with back pressure.

I think that a postgres table (with Repo.stream) or a big file could be a better example. A situation where the amount of data that comes in could eventually saturate your application and slow everything down.

2 Likes

Thanks for the explanation. I did feel like I was trying to connect the positive ends of two magnets, but thought maybe there was some justification or specific use case.

1 Like

maybe someone has an example where the two technologies could work well togheter. So far I didn’t find it :slight_smile:

1 Like

check out https://github.com/pma/wabbit.
its from the creator of the Elixir amqp module showing how to use it with gen_stage.

1 Like

Yes. I saw this library earlier. However, I am curious if the library is necessary. Or if, as @matteosister states, does GenStage make sense with RabbitMQ.

1 Like

Do you know of a more robust example of using RabbitMQ than the example tutorial on the RabbitMQ site? Seems overly simple and does not take advantage of GenServer.

1 Like

Nvm. The AMQP Elixir Github page shows an example using GenServer. I should have looked first.

1 Like