Fl4m3Ph03n1x
Background
I found out about Process.info which gives you information about a running process, such as the number of reductions and so on. However I need to know the number of unhandled messages a process has received during its life time.
Question
Is there a way to find this out, without me having to hard code it manually into each process?
Trending in Questions
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
Hello,
I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
Hi everyone,
I am toying with the idea of building a “match maker” for giving personal help to people that wants to start coding.
I sta...
New
Documentation
While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
So my question is quite simple and i have found no conclusive answer on forum, google or AI.
Should we use :erlang.float for Integer to ...
New
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New
apply_graft/2 doesn’t rewrite an add_many sub-workflow’s deps on an add step. Grafted jobs cancel with “upstream job was deleted”
Version...
New
Other Trending Topics
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hi there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Hi everyone!
The first release candidate for the Expert language server project is now available!
We’ve published a press release detai...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixirconf-us
- #ai
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #hex
- #security










Showing Posts 7 to 1- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
rvirding
I think you may be confusing what happens in a process and in a behaviour.
A process consumes messages using
receive. Unconsumed messages are left in the process message queue until they are consumed with areceive, they never go away by themselves.message_queue_lenreturns the number of messages currently in the message queue. The system does not keep count of the total number of messages that have arrived to a process.Note that there is no default
handle_infoor equivalent for a process.The generic code in behaviours generally have a top-level
receiveloop which processes every message it finds in the message queue. Through the format of the message it knows which callback function to call to process the message. Thehandle_infocallback is the one which is called when and unrecognised message arrives, one that hasn’t been sent with acallor acastnor is an OTP system message. This is something which is handle by the behaviour so the message queue will never be allowed to build up.The behaviour does not keep count of the total number of messages which has arrived at the process but it does keep count of the number of messages which it has processed in the top-loop. You can query this using
:sys.statistics/2to query the behaviour. Note that this is implemented by the generic behaviour code and is not not something that is implemented by the system for all processes.A final note. The basic concurrency model in Erlang and Elixir is very very simple and is based on four main ideas: isolated processes, asynchronous sending of messages, selective receive, and timeouts in the receive. Everything else, for example how behaviours behave, is explicitly built on top of this.
Sorry this became a bit longer than planned. I hope correctly understood what you were asking about.
NobbZ
No one deals with unhandled messages, that’s what makes them unhandled.
You can ask the BEAM for a list of pids and then check their message queue lengths, if that is greater than 0, then there are messages which have not yet been read by that process. This might have different reasons. Either messages come in faster as you are able to process, or there is no
receiveclause (so far) that matches them.Also if it’s only about that message, then you need to find a way to count them yourself. Should be trivial for any process you manage yourself.
keathley
As far as I know there’s no built in metric for this. You’ll need to create your own handle_info call and instrument this yourself.
Fl4m3Ph03n1x
So if the message is handled (consumed without error), shouldn’t the
message_queue_lenalways be 0?How does checking for
message_queue_lenhelp me find out which process are dealing with unhandled messages?NobbZ
When the default implementation of handle_info spits out that log message, it has received and therefore handled it, from the BEAMs viewpoint at least.
Fl4m3Ph03n1x
I don’t understand what you are trying to communicate.
According to my knowledge, when a process receives a message, if it doesn’t know what to do it with (because there is a missing
handle_infofor example) the process simply consumes the message, spits and error and moves on.The key here is the phrase “consumes the message”, meaning it removes it from the message’s queue and moves on.
Is my understanding of message handling incorrect?
NobbZ
You can find the message queue length via the function you mentioned. All of them are currently unhandled.