~ubuntu-branches/ubuntu/saucy/rabbitmq-server/saucy

« back to all changes in this revision

Viewing changes to plugins-src/rabbitmq-federation/src/rabbit_federation_app.erl

  • Committer: Package Import Robot
  • Author(s): Emile Joubert
  • Date: 2012-11-19 11:42:31 UTC
  • mfrom: (0.2.18) (0.1.32 sid)
  • Revision ID: package-import@ubuntu.com-20121119114231-hvapkn4akng09etr
Tags: 3.0.0-1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
 
27
27
-include_lib("amqp_client/include/amqp_client.hrl").
28
28
-import(rabbit_misc, [pget/3]).
29
 
-import(rabbit_federation_util, [pget_bin/2, pget_bin/3]).
30
29
 
31
30
start(_Type, _StartArgs) ->
32
 
    {ok, Xs} = application:get_env(exchanges),
33
 
    [declare_exchange(X) || X <- Xs],
34
31
    rabbit_federation_link:go(),
35
32
    supervisor:start_link({local, ?MODULE}, ?MODULE, []).
36
33
 
37
34
stop(_State) ->
38
35
    ok.
39
 
 
40
 
%%----------------------------------------------------------------------------
41
 
 
42
 
declare_exchange(Props) ->
43
 
    {ok, DefaultVHost} = application:get_env(rabbit, default_vhost),
44
 
    VHost = pget_bin(virtual_host, Props, DefaultVHost),
45
 
    Params = rabbit_federation_util:local_params(VHost),
46
 
    {ok, Conn} = amqp_connection:start(Params),
47
 
    {ok, Ch} = amqp_connection:open_channel(Conn),
48
 
    XNameBin = pget_bin(exchange, Props),
49
 
    amqp_channel:call(
50
 
      Ch, #'exchange.declare'{
51
 
        exchange    = XNameBin,
52
 
        type        = <<"x-federation">>,
53
 
        durable     = pget(durable,     Props, true),
54
 
        auto_delete = pget(auto_delete, Props, false),
55
 
        internal    = pget(internal,    Props, false),
56
 
        arguments   =
57
 
            [{<<"upstream-set">>, longstr, pget_bin(upstream_set, Props)},
58
 
             {<<"type">>,         longstr, pget_bin(type,         Props)}]}),
59
 
    amqp_channel:close(Ch),
60
 
    amqp_connection:close(Conn),
61
 
    ok.
62
 
 
63
36
%%----------------------------------------------------------------------------
64
37
 
65
38
init([]) -> {ok, {{one_for_one, 3, 10}, []}}.