[erlang-questions] Erlang - supervised gen_server to drain off a queue

Art Beall arthurbeall@REDACTED
Sat Dec 29 17:47:39 CET 2012

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.

>Hi guys,
>I'm just trying to bring Erlang into my company - it's a hard road, but
>we might eventually use it for at least some of our projects. I want to
>get started by changing a small piece of code that reads an AMQP queue
>and appends the contents of each message to a file. To be more specific,
>there are multiple producers for that queue (which produce error
>messages, if any) and there's this consumer which gets the error
>messages from the queue and updates a file with them. Now, this piece of
>software has always been problematic for us, for one reason or another -
>it's not reliable and when it fails it might bring the AMQP broker to
>its knees because of the number of messages that are not consumed.
>I'd like to change this code with some Erlang code - maybe with a
>supervision tree so that if/when the server fails, it gets automatically
>restarted. I was thinking of trying a gen_server, but then I figured out
>that there's no client of the server, the code just has to constantly
>pull data out of that queue.
>Any good hints on how to get started on this ? What's the OTP way of
>doing this kind of things?
>Thank you!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20121229/96c6ab1f/attachment.htm>

More information about the erlang-questions mailing list