TinyMQ

73 views
Skip to first unread message

Evan Miller

unread,
Aug 29, 2012, 11:44:23 AM8/29/12
to ChicagoBoss
Hi everyone,

If you've ever wanted to use Chicago Boss's built-in message queue in
a non-CB project, today is your lucky day. I finally got around to
splitting off the "bmq" modules into their own project. To prevent
confusion between the API layer (BossMQ) and the message queue itself
(BMQ), I am rechristening the latter. I always thought "Tiny" was a
great name for a criminal henchman, so I am pleased to announce the
creation of TinyMQ:

https://github.com/evanmiller/tinymq

TinyMQ is a simple, channel-based, in-memory message queue system with
an API very similar to BossMQ. The code base is very small, under 250
lines. TinyMQ follows OTP principles and will preserve state across
code reloads. It is ideal for simple, ad-hoc messaging applications
that can fit on a single machine.

The main drawback right now is that all of the message channels reside
on one Erlang node. As a result, it doesn't support failover and won't
scale to run on a large cluster. But hey, that's all you get for 250
LoC.

The code itself has been part of CB for over a year now, so it should
be nice and stable. But let me know if you encounter problems.

Happy messaging!

Evan

--
Evan Miller
http://www.evanmiller.org/

Max Lapshin

unread,
Aug 29, 2012, 11:48:57 AM8/29/12
to chica...@googlegroups.com
How can I subscribe simultaneously on two channels with synchronous API?

Evan Miller

unread,
Aug 29, 2012, 12:11:24 PM8/29/12
to chica...@googlegroups.com
tinymq:pull(Channel1, now, self()),
tinymq:pull(Channel2, now, self()),
receive
...
end

On Wed, Aug 29, 2012 at 10:48 AM, Max Lapshin <max.l...@gmail.com> wrote:
> How can I subscribe simultaneously on two channels with synchronous API?



Max Lapshin

unread,
Aug 29, 2012, 12:12:42 PM8/29/12
to chica...@googlegroups.com
got it.

Max Lapshin

unread,
Aug 29, 2012, 4:41:05 PM8/29/12
to chica...@googlegroups.com
I'm trying to use synchronous API, but I can't get blocking behaviour:
tinymq replies with empty message list:

> tinymq:poll(<<"default_channel">>, tinymq:now(<<"default_channel">>)).
{ok,1346272830861399,[]}

I don't see any place in code, where execution is blocked unless
message arrives.

Evan Miller

unread,
Aug 29, 2012, 4:52:39 PM8/29/12
to chica...@googlegroups.com
"poll" is non-blocking. You can use pull/receive to have blocking
behavior. I suppose I could implement a convenience function to make
this easier.

Max Lapshin

unread,
Aug 29, 2012, 4:54:38 PM8/29/12
to chica...@googlegroups.com
So what is the difference?

Evan Miller

unread,
Aug 29, 2012, 4:57:22 PM8/29/12
to chica...@googlegroups.com
pull should be renamed "subscribe". The calling process will receive
an async Erlang message when channel messages are available.

On Wed, Aug 29, 2012 at 3:54 PM, Max Lapshin <max.l...@gmail.com> wrote:
> So what is the difference?



Reply all
Reply to author
Forward
0 new messages