nathanl

nathanl

Monitor RabbitMQ queue length from Elixir?

Has anybody used Elixir to check the length of a RabbitMQ queue? It can be done with declare_queue, but it’s ugly - you have to pass the exact option you originally declared the queue with, plus :passive.

The use case is to detect when the system is backing up and respond accordingly.

Most Liked

collegeimprovements

collegeimprovements

If you can use GenRmq then it has message count, message_count functions.

nathanl

nathanl

@collegeimprovements Oh thanks - that led me to the underlying function: https://hexdocs.pm/amqp/1.4.2/AMQP.Queue.html#message_count/2 . Works great!

nathanl

nathanl

For anyone who stumbles on this later: AMQP only supports getting the number of messages that are “Ready”, not those that are “unacked”. For the latter, you might have to use RabbitMQ’s REST API. See https://stackoverflow.com/questions/63018151/can-i-see-the-count-of-unacked-messages-in-rabbitmq-via-an-amqp-client

My system that consumes from the queue is using Broadway. In normal load, I basically never see any messages as “ready” because they’re quickly grabbed up by my Broadway pipeline. By queueing a lot of messages and putting a Process.sleep(:infinity) in my handle_message, I can see that my system will have at most N unacked messages at a time. So if I see any messages in the “ready” count, I can basically assume that there are N more being handled at the moment, which is a good enough indicator to decide whether the system is getting overloaded.

Where Next?

Popular in Questions Top

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
dotdotdotPaul
Okay, I'm having a heck of a time trying to figure out how to best handle the validation of belongs_to associations in Ecto. I'm sure I'...
New
lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New
quazar
How to set Jason to encode all fields in ecto schema, I don’t care about security and implementing only is taking long list of attributes...
New
lastday4you
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
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
9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New

Other popular topics Top

openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
sergio
I couldn’t find any guides that worked well with Phoenix 1.6.0 and esbuild. I hope this helps people test the waters and eases you into t...
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
shahryarjb
Hello, I have map which I want to convert it to string like this: the map: %{last_name: "tavakkoli", name: "shahryar"} the string I ne...
New
johnnyicon
Hi all, I've just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage. I'm trying to use Postg...
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
aesmail
Hello guys, I have finally made it. I created an admin interface for a framework. It’s been on my todo list for years and with the curre...
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New
jay1
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New

We're in Beta

About us Mission Statement