Start with gen_bunny for Erlang You need to install rebar, the build-tool for Erlang before you can install gen_bunny. ```ruby git clone git://github.com/basho/rebar.git cd rebar ./bootstrap Now you can install and test gen_bunny: git clone git://github.com/boorad/gen_bunny.git cd gen_bunny make make test Hello World Example for Erlang and RabbitMQ erl -pa `find . -type d -name ebin` %% Load Records Used With Rabbit: > rr("deps/rabbit_common/include/rabbit_framing.hrl"). %% Start gen_bunny as a producer using the default exchange: > bunnyc:start_link(mq_producer, {network, "localhost", 5672, {<<"guest">>, <<"guest">>}, <<"/">>}, {#'exchange.declare'{exchange = <<"">>, durable=true}}, [] ). %% Start another gen_bunny as a producer/consumer using a named queue and exchange: > bunnyc:start_link(mq_consumer, {network, "localhost"}, {<<"myexchange">>, <<"myqueue">>, <<"">>}, []). %% Publish a message to "myqueue" via the default exchange: > bunnyc:publish(mq_producer, <<"myqueue">>, <<"hello, world">>). %% Fetch the message: > bunnyc:get(mq_consumer, true). {#'basic.get_ok'{delivery_tag = 1,redelivered = false, exchange = <<>>,routing_key = <<"myqueue">>, message_count = 0}, {amqp_msg,#'P_basic'{content_type = undefined, content_encoding = undefined,headers = undefined, delivery_mode = undefined,priority = undefined, correlation_id = undefined,reply_to = undefined, expiration = undefined,message_id = undefined, timestamp = undefined,type = undefined,user_id = undefined, app_id = undefined,cluster_id = undefined}, <<"hello, world">>}} %% Publish a message to "myqueue" via the "myexchange" exchange: > bunnyc:publish(mq_consumer, <<"">>, <<"hello again">>). %% Fetch the message: > bunnyc:get(mq_consumer, true). {#'basic.get_ok'{delivery_tag = 2,redelivered = false, exchange = <<"myexchange">>,routing_key = <<>>, message_count = 0}, {amqp_msg,#'P_basic'{content_type = undefined, content_encoding = undefined,headers = undefined, delivery_mode = undefined,priority = undefined, correlation_id = undefined,reply_to = undefined, expiration = undefined,message_id = undefined, timestamp = undefined,type = undefined,user_id = undefined, app_id = undefined,cluster_id = undefined}, <<"hello again">>}} %% Shut it down: > bunnyc:stop(mq_consumer). > bunnyc:stop(mq_producer). You can see the queued messages on RabbitMQ Management via localhost:5567 when you use bunnyc:publish and see the count updated when you retrieve via bunnyc:get. For Rubyists, it’s probably less obscure and more natural to use minion. I am just amused with Erlang language. If I like it and can see a practical use for it, expect more posts about it." />

Share on Facebook

Share on Twitter

We got your feedback!

Recent posts