Rabbit farms is a standalone service for publishing messages to RabbitMQ from other another erlang apps.
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.
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">>}]
]}
]}]
}.
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
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