[rabbitmq-discuss] Introducing bunny_farm: an erlang client for RabbitMQ
Brian Rowe
rowe at muxspace.com
Sat Apr 30 14:24:18 BST 2011
Alexis,
A link would be great. I'm actively developing this library so any bug reports/feature requests will be addressed/accommodated quickly.
Regards,
Brian
On Apr 28, 2011, at 4:20 AM, Alexis Richardson wrote:
> 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