1
%% The contents of this file are subject to the Mozilla Public License
2
%% Version 1.1 (the "License"); you may not use this file except in
3
%% compliance with the License. You may obtain a copy of the License
4
%% at http://www.mozilla.org/MPL/
6
%% Software distributed under the License is distributed on an "AS IS"
7
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
8
%% the License for the specific language governing rights and
9
%% limitations under the License.
11
%% The Original Code is RabbitMQ Federation.
13
%% The Initial Developer of the Original Code is VMware, Inc.
14
%% Copyright (c) 2007-2012 VMware, Inc. All rights reserved.
17
-module(rabbit_federation_old_app).
19
-behaviour(application).
20
-export([start/2, stop/1]).
22
%% This does the same dummy supervisor thing as rabbit_mgmt_app - see the
24
-behaviour(supervisor).
27
-include_lib("amqp_client/include/amqp_client.hrl").
28
-import(rabbit_misc, [pget/3]).
29
-import(rabbit_federation_old_util, [pget_bin/2, pget_bin/3]).
31
start(_Type, _StartArgs) ->
32
{ok, Xs} = application:get_env(rabbitmq_old_federation, exchanges),
33
[declare_exchange(X) || X <- Xs],
34
rabbit_federation_old_link:go(),
35
supervisor:start_link({local, ?MODULE}, ?MODULE, []).
40
%%----------------------------------------------------------------------------
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_old_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),
50
Ch, #'exchange.declare'{
52
type = <<"x-federation">>,
53
durable = pget(durable, Props, true),
54
auto_delete = pget(auto_delete, Props, false),
55
internal = pget(internal, Props, false),
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),
63
%%----------------------------------------------------------------------------
65
init([]) -> {ok, {{one_for_one, 3, 10}, []}}.