<html><body><div style="color:#000; background-color:#fff; font-family:verdana, helvetica, sans-serif;font-size:10pt"><div><span>One way is to use the timeout in the return tuple to gen_server. After the timeout period, gen_server will call your handle_info function with the atom timeout. You can handle the queue then.</span></div><div><span></span> </div><div><span><a href="http://www.erlang.org/doc/man/gen_server.html#Module:handle_info-2">http://www.erlang.org/doc/man/gen_server.html#Module:handle_info-2</a></span></div><div><span></span> </div><div> </div><div> </div><blockquote style="margin-right: 0px;" dir="ltr"><div>Art<br><br>Hi guys,<br><br>I'm just trying to bring Erlang into my company - it's a hard road, but<br>we might eventually use it for at least some of our projects. I want to<br>get started by changing a small piece of code that reads an AMQP queue<br>and appends the contents of each message to a file. To
be more specific,<br>there are multiple producers for that queue (which produce error<br>messages, if any) and there's this consumer which gets the error<br>messages from the queue and updates a file with them. Now, this piece of<br>software has always been problematic for us, for one reason or another -<br>it's not reliable and when it fails it might bring the AMQP broker to<br>its knees because of the number of messages that are not consumed.<br><br>I'd like to change this code with some Erlang code - maybe with a<br>supervision tree so that if/when the server fails, it gets automatically<br>restarted. I was thinking of trying a gen_server, but then I figured out<br>that there's no client of the server, the code just has to constantly<br>pull data out of that queue.<br><br>Any good hints on how to get started on this ? What's the OTP way of<br>doing this kind of things?<br><br>Thank you!<br><br> </div></blockquote></div></body></html>