stefanchrobot

stefanchrobot

Handling errors in RabbitMQ consumer

I’m trying to set up a RabbitMQ consumer using the amqp library. I want to process multiple messages concurrently and properly handle errors (properly reject message if a processing error occurs). How would I go about doing this?

The “Setup a consumer GenServer” example defines a single GenServer that spawns a new process for each incoming message which paired with prefetch_count > 1 allows for concurrent processing of the messages.

How do I make sure that those processes are cleaned up properly? Is spawn_link enough to shut them down when the parent GenServer is shutting down?
Should those processes live under a supervision tree?
How would I implement a timeout for processing of a message (kill it after 5seconds)?
The example says “You might also want to catch :exit signal in production code.” Why? When would that happen? How do I do that?
Are these consumer processes a use case for Tasks or DynamicSupervisor?
Or should this be set up totally differently, i.e. have a Supervisor with N workers where each one is a consumer on a shared connection?

Most Liked

blatyo

blatyo

Conduit Core Team

You might find my library useful for this. It handles all the process and error stuff for you.

These slides give you idea of the code you would write.

Even if you don’t use it, you can see how those types of things are handled here.

EDIT: If you do use it and discover something that’s not well documented. Please file a ticket or a PR for it.

Where Next?

Popular in Questions Top

Tee
can someone please explain to me how Enum.reduce works with maps
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
makeitrein
Hey all, just started picking up Elixir last week and am writing a scraper as a learning project. Baby step #1 is extracting the number ...
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
hpopp
To simplify some tasks at work, I wrote and published this package yesterday. It’s a simple macro that enables Access behaviour on struct...
New
beno
I will often find my self writing things similar to: case some_value do nil -> something() "" -> something() _ -> someth...
New
Fl4m3Ph03n1x
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: ) Hello all, this is ...
New
jc00ke
Expanding on this topic: https://forum.elixirforum.net/t/map-typespec-question/19217 Let’s say I have a map with required and optional k...
New
jay1
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New

Other popular topics Top

yurko
Here are few pieces of (common) Linux knowledge that we use for reasonably small one server apps. We use Ubuntu but this should work for ...
New
shahryarjb
Hello, I get Persian date from my client and convert it to normal calendar like this: def jalali_string_to_miladi_english_number(persi...
New
Tee
can someone please explain to me how Enum.reduce works with maps
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 record...
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
ycv005
I have followed this StackOverflow post to install the specific version of Erlang. And When I am running mix ecto.setup then getting fol...
New
vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
script
If I have a string “1000 cfu/ml” . I want to remove the characters and / and space . So the string is like this "1000" What is the ...
New
chensan
I have a User schema with a :from_id field set to type :string: defmodule TweetBot.Repo.Migrations.CreateUsers do use Ecto.Migration ...
New
josevalim
Hi everyone, One of the features added to Elixir early on to help integration with Erlang code was the idea of overridable function defi...
New

We're in Beta

About us Mission Statement