Skip to content

Commit 99fea41

Browse files
committed
Shovels: more detailed error message
1 parent 9f39f60 commit 99fea41

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

deps/rabbitmq_shovel/src/rabbit_shovel_worker.erl

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ handle_cast(init, State = #state{config = Config0}) ->
8282
catch E:R ->
8383
?LOG_ERROR("Shovel ~ts could not connect to source: ~p ~p",
8484
[human_readable_name(maps:get(name, Config0)), E, R]),
85-
{stop, {shutdown, restart}, State}
85+
{stop, {shutdown, inbound_conn_failed}, State}
8686
end;
8787
handle_cast(connect_dest, State = #state{config = Config0}) ->
8888
try rabbit_shovel_behaviour:connect_dest(Config0) of
@@ -93,7 +93,7 @@ handle_cast(connect_dest, State = #state{config = Config0}) ->
9393
catch E:R ->
9494
?LOG_ERROR("Shovel ~ts could not connect to destination: ~p ~p",
9595
[human_readable_name(maps:get(name, Config0)), E, R]),
96-
{stop, {shutdown, restart}, State}
96+
{stop, {shutdown, outbond_conn_failed}, State}
9797
end;
9898
handle_cast(init_shovel, State = #state{config = Config}) ->
9999
%% Don't trap exits until we have established connections so that
@@ -227,6 +227,20 @@ terminate({{shutdown, {server_initiated_close, Code, Reason}}, _}, State = #stat
227227
{terminated, "needed a restart"}),
228228
close_connections(State),
229229
ok;
230+
terminate({shutdown, outbond_conn_failed}, State = #state{name = Name}) ->
231+
?LOG_ERROR("Shovel ~ts is stopping because if failed to connect to destination",
232+
[human_readable_name(Name)]),
233+
rabbit_shovel_status:report(State#state.name, State#state.type,
234+
{terminated, "failed to connect to destination"}),
235+
close_connections(State),
236+
ok;
237+
terminate({shutdown, inbound_conn_failed}, State = #state{name = Name}) ->
238+
?LOG_ERROR("Shovel ~ts is stopping because it failed to connect to source",
239+
[human_readable_name(Name)]),
240+
rabbit_shovel_status:report(State#state.name, State#state.type,
241+
{terminated, "failed to connect to source"}),
242+
close_connections(State),
243+
ok;
230244
terminate(Reason, State = #state{name = Name}) ->
231245
?LOG_ERROR("Shovel ~ts is stopping, reason: ~tp", [human_readable_name(Name), Reason]),
232246
rabbit_shovel_status:report(State#state.name, State#state.type,

0 commit comments

Comments
 (0)