[erlang-questions] monitor message queue of a process

Zoltan Lajos Kis <>
Wed Apr 21 21:10:54 CEST 2010

Definitely not generic...
But as a quick hack you can set a trace flag on your process in order to 
receive a message whenever the process receives one:
erlang:trace(Pid, true, ['receive', {tracer, MonitorPid}]).
This way you only need to check the queue length after the first n trace 
messages, then after n-m messages, etc...


On 4/21/2010 7:26 PM, Roberto Ostinelli wrote:
> dear list,
> i would like to know if there's a native way to monitor and react on a
> message queue of a process, without the need to modify the process
> itself.
> it's quite easy to get the message queue length using
> erlang:process_info/2, however i would need this monitoring done not
> in a polling-way [which would periodically check for this
> information], but i would love to have some kind of a message when the
> queue length is modified and satisfies some requisites.
> i'm trying to figure out a way to provide some kind of generic
> buffering technique to solve selective receives' snowball effect that
> is being discussed so much lately.
> ideas welcome.
> r.
> ________________________________________________________________
> erlang-questions (at) erlang.org mailing list.
> See http://www.erlang.org/faq.html
> To unsubscribe; mailto:

More information about the erlang-questions mailing list