{reply, Connection, Connection}.
start_link_connection() ->
- {ok, Pid} = amqp_connection:start(#amqp_params_network{}),
+ Username = get_config(username, "guest"),
+ Password = get_config(password, "guest"),
+ VHost = get_config(vhost, "/"),
+ {ok, Pid} = amqp_connection:start(
+ #amqp_params_network{username = Username,
+ password = Password,
+ virtual_host = VHost
+ }),
link(Pid),
{ok, Pid}.
+
+get_config(Key, Default) ->
+ DataList = case config:get_config(amqp) of
+ [Config] ->
+ case lists:keyfind(Key, 1, Config) of
+ {Key, Data} -> Data;
+ false -> Default
+ end;
+ [] ->
+ Default
+ end,
+ list_to_binary(DataList).