[rabbitmq-discuss] Introducing bunny_farm: an erlang client for RabbitMQ

Alexis Richardson alexis at rabbitmq.com
Thu Apr 28 10:20:36 BST 2011


Brian

Many thanks!  We shall add a link to this from the web site.

alexis


On Sat, Apr 23, 2011 at 11:29 PM, Brian Rowe <rowe at muxspace.com> wrote:
> Hello,
>
> For any erlang users out there, I wanted to introduce a rabbitmq client library I've been working on for a little while called bunny_farm. This library wraps up the wiring for connecting to a message queue and provides queue-based implementations of gen_server and gen_fsm behaviors. These behaviors (called gen_qserver and gen_qfsm, respectively) can subscribe to multiple exchanges with different routing keys and will dispatch messages received from the queue to handle_cast and Module:StateName/2 for standard messages, wrapping the payload in a tuple for the sake of pattern matching.
>
> handle_cast({<<RoutingKey/binary>>, Payload}, State)
>
> These behaviors also understand RPC semantics (if the reply_to field is populated) and will instead dispatch to handle_call and Module:StateName/3 instead. Under this scenario, the reply is automatically sent to the caller based on the contents of the routing key, which can be to a different exchange. I introduce a special format for the reply_to field so that if the key is colon-separated, the first token is used as the exchange: <<"exchange:routing_key">>. If no exchange is specified, then it defaults to the exchange the message was received on.
>
> Publishing messages are as easy as consuming messages:
>  BusHandle = bunny_farm:open(<<"exchange">>)
>  bunny_farm:publish([{key1,message}], <<"routing_key.1">>, BusHandle)
>
> Messages can be encoded as either erlang binaries or BSON, depending on the need. When receiving messages, the library auto-detects the format.
>
> The bunny_farm library is available on github at https://github.com/muxspace/bunny_farm. There is an example gen_qserver implementation and gen_qfsm implementation in the test directory. I'm hopeful this is useful for the community and any feedback is warmly appreciated.
>
>
> Regards,
> Brian Rowe
>
> P.S. Apologies if this is not the right list for this announcement.
>
> _______________________________________________
> rabbitmq-discuss mailing list
> rabbitmq-discuss at lists.rabbitmq.com
> https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
>


More information about the rabbitmq-discuss mailing list