Giter Site home page Giter Site logo

noblesamurai / gen_bunny Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mochi/gen_bunny

0.0 7.0 0.0 1.62 MB

An RabbitMQ client library for erlang which aims at being easy to use for simple publisher and subscriber applications.

Home Page: http://travis-ci.org/#!/dreid/gen_bunny/

License: MIT License

Shell 0.90% Erlang 50.23% JavaScript 48.87%

gen_bunny's Introduction

gen_bunny

gen_bunny is a RabbitMQ client library for erlang whose primary goal is to be easy to use. Especially for simple publisher and consumer applications.

image

Getting the code

One of gen_bunny's goals is to make it as easy to get all the required code build it, and start using it as possible. To achieve this goal we've used rebar for dependency management, as our build tool, and as our test runner.

To get a local copy of gen_bunny only the following steps are needed.

git clone http://github.com/dreid/gen_bunny.git
cd gen_bunny
make
make test

Getting Started

After cloning and compiling the code as above, start two terminal sessions (in tabs, or with screen or tmux). Start RabbitMQ in the first session:

rabbitmq-server

In the second terminal, start an erlang shell:

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).

Using rebar

Using rebar for dependency management means that gen_bunny can also be used as a rebar dependency. This is the preferred way to get gen_bunny into your application, and in fact at this time the only supported way.

To depend on gen_bunny in your application simply add the following line to your project's rebar.config file.

{deps, [{gen_bunny, ".*",
         {git, "http://github.com/dreid/gen_bunny.git", ""}}]}.

After that simply using rebar get-deps compile will fetch the necessary amqp_client and rabbit_common dependencies and build them along with gen_bunny.

gen_bunny's People

Contributors

dreid avatar argv0 avatar danielsdeleo avatar etrepum avatar boorad avatar faal avatar

Watchers

edwardt avatar Andrew Harris avatar Julian Thatcher avatar Tim Allen avatar James Cloos avatar Dear Me. avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.