Skip to content

erlang-china/rabbit_farms

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rabbit_farms

Rabbit farms is a standalone service for publishing messages to RabbitMQ from other another erlang apps.

This is a beta version.

Usage scenario


Other (external) erlang applications publish messages to RabbitMQ without needing to reference the amqp_client, using it just like the gen_server call/cast API.

Usage:


Configure the rabbit_farms.app

{env, [{config, "etc/rabbit_farms.config"}]}

Configure the etc/rabbit_farms.config

{rabbit_farms, [{default, [ {username, <<"guest">>},
                            {password, <<"V2pOV2JHTXpVVDA9">>},
                            {virtual_host, <<"/">>},
                            {host, "localhost"},
                            {port, 5672},
                            {feeders,[
                                       [{channel_count,1},
                                        {exchange, <<"tracking.logs">>},
                                        {type, <<"topic">>}]
                                     ]}
                          ]},
                {notification,[ {username, <<"guest">>},
                                {password, <<"V2pOV2JHTXpVVDA9">>},
                                {virtual_host, <<"/">>},
                                {host, "localhost"},
                                {port, 5672},
                                {feeders,[
                                           [{channel_count,1},
                                           {exchange, <<"app.notification">>},
                                           {type, <<"topic">>}]
                                         ]}
                              ]}]
}.

publish

    1>RabbitCarrot = #rabbit_carrot{farm_name   = tracking, 
                                    exchange    = <<"tracking.log">>, 
                                    routing_key = <<"routing_key">>, 
                                    message     = <<"">>}.
      #rabbit_carrot{farm_name    = tracking,
                     exchange     = <<"tracking.log">>,
                     routing_key  = <<"routing_key">>,message = <<>>,
                     content_type = undefined}
    2>rabbit_farms:publish(cast, RabbitCarrot). %%asynchronous
    3>rabbit_farms:publish(call, RabbitCarrot). %%synchronization

batch publish

    1>Body1 = #rabbit_carrot_body{routing_key = <<"routing_key">>, 
                                  message     = <<"message1">>}.
      #rabbit_carrot_body{routing_key = <<"routing_key1">>,
                          message     = <<"message1">>}
                    
    2>Body2 = #rabbit_carrot_body{routing_key = <<"routing_key">>, 
                                  message     = <<"message2">>}.
      #rabbit_carrot_body{routing_key = <<"routing_key2">>,
                          message     = <<"message2">>}
                    
    3>RabbitCarrots = #rabbit_carrots{farm_name            = tracking,
                                      exchange             = <<"tracking.log">>, 
                                      rabbit_carrot_bodies = [Body1,Body2]}.
    
      #rabbit_carrots{
                        farm_name = tracking,
                        exchange  = <<"tracking.log">>,
                        rabbit_carrot_bodies = 
                            [#rabbit_carrot_body{
                                 routing_key = <<"routing_key">>,
                                 message     = <<"message1">>},
                             #rabbit_carrot_body{
                                 routing_key = <<"routing_key">>,
                                 message     = <<"message2">>}],
                        content_type = undefined}

    4>rabbit_farms:publish(cast, RabbitCarrots). %%asynchronous
    5>rabbit_farms:publish(call, RabbitCarrots). %%synchronization

About

Rabbit farms is a standalone service for publish RabbitMQ messages

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages