Merged bug20937 into default
This commit is contained in:
commit
51ebae45d5
|
|
@ -33,6 +33,7 @@
|
||||||
channel_max,
|
channel_max,
|
||||||
heartbeat,
|
heartbeat,
|
||||||
driver,
|
driver,
|
||||||
|
port,
|
||||||
channels = dict:new() }).
|
channels = dict:new() }).
|
||||||
|
|
||||||
-record(channel_state, {number,
|
-record(channel_state, {number,
|
||||||
|
|
|
||||||
|
|
@ -33,8 +33,8 @@
|
||||||
-export([init/1, terminate/2, code_change/3, handle_call/3, handle_cast/2,
|
-export([init/1, terminate/2, code_change/3, handle_call/3, handle_cast/2,
|
||||||
handle_info/2]).
|
handle_info/2]).
|
||||||
-export([open_channel/1, open_channel/3]).
|
-export([open_channel/1, open_channel/3]).
|
||||||
-export([start/2, start/3, start/4, close/2]).
|
-export([start/2, start/4, start/5, close/2]).
|
||||||
-export([start_link/2, start_link/3, start_link/4]).
|
-export([start_link/2, start_link/4, start_link/5]).
|
||||||
|
|
||||||
%%---------------------------------------------------------------------------
|
%%---------------------------------------------------------------------------
|
||||||
%% AMQP Connection API Methods
|
%% AMQP Connection API Methods
|
||||||
|
|
@ -48,31 +48,32 @@ start(User, Password, ProcLink) when is_boolean(ProcLink) ->
|
||||||
password = Password,
|
password = Password,
|
||||||
vhostpath = <<"/">>},
|
vhostpath = <<"/">>},
|
||||||
{ok, Pid} = start_internal(InitialState, amqp_direct_driver, ProcLink),
|
{ok, Pid} = start_internal(InitialState, amqp_direct_driver, ProcLink),
|
||||||
Pid;
|
Pid.
|
||||||
|
|
||||||
%% Starts a networked conection to a remote AMQP server.
|
%% Starts a networked conection to a remote AMQP server.
|
||||||
start(User, Password, Host) ->
|
start(User, Password, Host, Port) ->
|
||||||
start(User, Password, Host, <<"/">>, false).
|
start(User, Password, Host, Port, <<"/">>, false).
|
||||||
|
|
||||||
start(User, Password, Host, VHost) ->
|
start(User, Password, Host, Port, VHost) ->
|
||||||
start(User, Password, Host, VHost, false).
|
start(User, Password, Host, Port, VHost, false).
|
||||||
|
|
||||||
start(User, Password, Host, VHost, ProcLink) ->
|
start(User, Password, Host, Port, VHost, ProcLink) ->
|
||||||
InitialState = #connection_state{username = User,
|
InitialState = #connection_state{username = User,
|
||||||
password = Password,
|
password = Password,
|
||||||
serverhost = Host,
|
serverhost = Host,
|
||||||
vhostpath = VHost},
|
vhostpath = VHost,
|
||||||
|
port = Port},
|
||||||
{ok, Pid} = start_internal(InitialState, amqp_network_driver, ProcLink),
|
{ok, Pid} = start_internal(InitialState, amqp_network_driver, ProcLink),
|
||||||
Pid.
|
Pid.
|
||||||
|
|
||||||
start_link(User, Password) ->
|
start_link(User, Password) ->
|
||||||
start(User, Password, true).
|
start(User, Password, true).
|
||||||
|
|
||||||
start_link(User, Password, Host) ->
|
start_link(User, Password, Host, Port) ->
|
||||||
start(User, Password, Host, <<"/">>, true).
|
start(User, Password, Host, Port, <<"/">>, true).
|
||||||
|
|
||||||
start_link(User, Password, Host, VHost) ->
|
start_link(User, Password, Host, Port, VHost) ->
|
||||||
start(User, Password, Host, VHost, true).
|
start(User, Password, Host, Port, VHost, true).
|
||||||
|
|
||||||
start_internal(InitialState, Driver, _Link = true) when is_atom(Driver) ->
|
start_internal(InitialState, Driver, _Link = true) when is_atom(Driver) ->
|
||||||
gen_server:start_link(?MODULE, [InitialState, Driver], []);
|
gen_server:start_link(?MODULE, [InitialState, Driver], []);
|
||||||
|
|
|
||||||
|
|
@ -40,8 +40,8 @@
|
||||||
% Driver API Methods
|
% Driver API Methods
|
||||||
%---------------------------------------------------------------------------
|
%---------------------------------------------------------------------------
|
||||||
|
|
||||||
handshake(State = #connection_state{serverhost = Host}) ->
|
handshake(State = #connection_state{serverhost = Host, port = Port}) ->
|
||||||
case gen_tcp:connect(Host, 5672, [binary, {packet, 0}, {active, false},
|
case gen_tcp:connect(Host, Port, [binary, {packet, 0}, {active, false},
|
||||||
{nodelay, true}]) of
|
{nodelay, true}]) of
|
||||||
{ok, Sock} ->
|
{ok, Sock} ->
|
||||||
ok = gen_tcp:send(Sock, amqp_util:protocol_header()),
|
ok = gen_tcp:send(Sock, amqp_util:protocol_header()),
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,10 @@ start_connection() ->
|
||||||
amqp_connection:start("guest", "guest").
|
amqp_connection:start("guest", "guest").
|
||||||
|
|
||||||
start_connection(Host) ->
|
start_connection(Host) ->
|
||||||
amqp_connection:start("guest", "guest", Host).
|
start_connection(Host, ?PROTOCOL_PORT).
|
||||||
|
|
||||||
|
start_connection(Host, Port) ->
|
||||||
|
amqp_connection:start("guest", "guest", Host, Port).
|
||||||
|
|
||||||
start_channel(Connection) ->
|
start_channel(Connection) ->
|
||||||
amqp_connection:open_channel(Connection).
|
amqp_connection:open_channel(Connection).
|
||||||
|
|
|
||||||
|
|
@ -81,7 +81,7 @@ hard_error_test() ->
|
||||||
%%---------------------------------------------------------------------------
|
%%---------------------------------------------------------------------------
|
||||||
|
|
||||||
new_connection() ->
|
new_connection() ->
|
||||||
amqp_connection:start("guest", "guest").
|
lib_amqp:start_connection().
|
||||||
|
|
||||||
test_coverage() ->
|
test_coverage() ->
|
||||||
rabbit_misc:enable_cover(),
|
rabbit_misc:enable_cover(),
|
||||||
|
|
|
||||||
|
|
@ -78,7 +78,7 @@ hard_error_test() ->
|
||||||
%% Common Functions
|
%% Common Functions
|
||||||
|
|
||||||
new_connection() ->
|
new_connection() ->
|
||||||
amqp_connection:start("guest", "guest", "localhost").
|
lib_amqp:start_connection("localhost").
|
||||||
|
|
||||||
test_coverage() ->
|
test_coverage() ->
|
||||||
rabbit_misc:enable_cover(),
|
rabbit_misc:enable_cover(),
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue