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

Loïc Hoguin essen@REDACTED
Sun Dec 30 04:28:20 CET 2012


This timeout only triggers if no message/cast/call was performed during 
the timeout period. So it's only useful for servers where more or less 
nothing happen.

On 12/29/2012 05:47 PM, Art Beall wrote:
> 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.
> http://www.erlang.org/doc/man/gen_server.html#Module:handle_info-2
>
>     Art
>
>     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!
>
>
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
>


-- 
Loïc Hoguin
Erlang Cowboy
Nine Nines
http://ninenines.eu



More information about the erlang-questions mailing list