tinymq -> subscriber gen_server only ever receives first push message

15 views
Skip to first unread message

justin....@gmail.com

unread,
Dec 15, 2014, 3:31:48 PM12/15/14
to chica...@googlegroups.com
Hi, playing with tinymq here.  I have a very simple gen_server which subscribes on initialisation as follows:

init([]) ->
    tinymq:subscribe(?MODULE, now, self()),
    {ok, #state{}}.

modified handle_info to dump any messages received (I'm assuming they appear at the handle_info level):

handle_info(Info, State) ->
    io:format("handle_info: ~w~n", [Info]),
    {noreply, State}.

then finally added a top- level function to push messages onto the queue:

send(Msg) ->
    tinymq:push(?MODULE, {msg, Msg}).

Now this works fine for the first message I send; message dumped to console by handle_info; but after that no other pushed messages are dumped.

Have I misunderstood how the tinymq subscribe API works ? Do I have to flush queues somewhere ?

TIA

justin....@gmail.com

unread,
Dec 18, 2014, 2:41:57 PM12/18/14
to chica...@googlegroups.com, justin....@gmail.com
"Subscribers are removed from the channel as soon as the first message is delivered, so to keep a subscription active you need to keep re-subscribing using the returned Timestamp as the input to the next call."
Reply all
Reply to author
Forward
0 new messages