Does anybody know of a good free program which can help me monitor the windows messages queued in a process' message queue?
WindowDetective seems to do the job!
http://sourceforge.net/projects/windowdetective/
Related
I am using AWS SQS with dead letter queues.
I can easily insert messages to the dead letter queue if I consume them, but I want messages that weren't consumed for like a hour to be moved to the dead letter queue automatically.
Is this possible?
Am I missing a configuration option?
Regards,
Ido
Dead letter queues are not designed for this purpose; they specifically handle the case where a message can be successfully received, but cannot be processed successfully (source). So in short, this is not currently possible. Alternatively, you could increase the message retention time so that the messages stay for longer on the queue giving your a consumer a chance to start listening again.
Hope that helps :)
I'm writing a TCP server in Erlang, using Ranch. The clients will reconnect immediately the connection is dropped, which means that one particular failure mode is listeners being started and killed dozens of times a second.
I'd like to detect this happening and publish statistics to statsd, for monitoring in production.
So, can I use something in Ranch to monitor when a listener is recycled? Or can I use something in Erlang to monitor process mortality for the entire node, without having to link to each process, and where those processes were started by some other supervisor, so I don't have a reference to them?
It's not a direct answer to my question, but I opted, instead, to have a separate process periodically polling ranch_server:count_connections(my_ref), and publish that to statsd.
As described here, I'm detecting that I've been forked by Phusion Passenger, and revive a background thread that is aggregating some data that will eventually get packaged and sent to a remote server after a set amount of time. But sometimes, before the thread wakes up from the sleep, the process disappears, and (according to my log messages, that report the PID when the thread wakes up), I never hear from it again. Any way to control or prevent this?
You shouldn't be creating threads within a Passenger hosted process. If Passenger doesn't think your process is busy servicing requests, it is free to shut it down without warning. Those background threads should be used only in the course of your request processing.
What you want is a background job processing facility like delayed_job to offload this.
I went through the documentation of the trace/3 BIF in Erlang. However, one observation I have made is that it cannot be used for tracing the consuming of messages from the mailbox. The flag 'receive' only traces when messages are added to a process's mailbox.
Is there any way one can trace events such as reading from the mailbox using the receive construct? If not, is there any reason why this isn't possible? It seems very strange that one can trace most kind of events in a program and the reading of messages from a mailbox is not traceable.
There is no such tool. You can only hope for call tracing of the handling function. It is rather easy in OTP applications since you can hook handle_....
I have a gen_server module that logs data to a file when a client process sends it data. What happens when two client processes send data at the same time to this module? Will the file operations conflict with each other? The erlang documentation is frustratingly unclear here.
Every Erlang process maintains a message queue. The process will fetch a message and handle the messages one by one.
In your example, if two clients calls the gen_server at the same time, these calls will become a message in the queue of gen_server process, and the gen_server will process these messages one by one. So no need to worry about a conflict.
But if one process has to handle too many messages from other processes, you'll need to think about the capacity of the process and optimize the design, or else it will become a bottleneck.
The gen_server runs in a separate process from your client process so when you do a call/cast to it you are actually sending messages to the server process.
All messages are placed in a process' message queue and processes handle their message one-by-one. If a message arrives while a process is busy then it is placed in the message queue. So log messages arriving concurrently will never interfere with each other as they will be processed sequentially.
This is not a property of the gen_server as such but a general property of all processes in erlang, which is why no mention of this is made in the gen_server documentation.
gen_server just handles requests in the order that they was done, not matter they was done from one process or many.
In case of writing to log there is no reason to worry about race-conditions.
Fortunately, the source for OTP is readily available at github, but the short answer is that gen_server runs in a loop, answering requests in order received, with no priority of one type (handle_cast, handle_call, or handle_info) over another.
Using handle_call can potentially be an issue, as the gen_server process will have to return before it can deal with the next cast/call/info in queue. For example, in a handle_call, avoid gen_server:call with self()!