diff options
| author | Michael Klishin <michael@clojurewerkz.org> | 2016-06-18 23:52:28 +0300 |
|---|---|---|
| committer | Michael Klishin <michael@clojurewerkz.org> | 2016-06-18 23:52:28 +0300 |
| commit | 81ff300a43640acd7a6c36f2dc31a73f8dc05bb2 (patch) | |
| tree | f49049417c435eccc9769fd1149eb40a0ac260ec /src | |
| parent | cd73f98a6d2a2b0b1c55b0a7f6aebfc05a32a5dc (diff) | |
| download | rabbitmq-server-git-81ff300a43640acd7a6c36f2dc31a73f8dc05bb2.tar.gz | |
Gracefully handle cases when logging exchange does not existrabbitmq_v3_6_3_milestone2
Client test suites that test connection recovery by
restarting RabbitMQ ocassionally lead to a situation when
amq.rabbitmq.log in the "/" vhost can be unavailable for a split
second.
Default vhost may or may not exist in general. So handle {error, not_found}
responses from rabbit_basic:publish/4 instead of potentially seriously
polluting logs with confusing exceptions.
While at it, return a sensible value from terminate/2.
Diffstat (limited to 'src')
| -rw-r--r-- | src/rabbit_error_logger.erl | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/rabbit_error_logger.erl b/src/rabbit_error_logger.erl index d847284243..3724b95e9d 100644 --- a/src/rabbit_error_logger.erl +++ b/src/rabbit_error_logger.erl @@ -69,7 +69,7 @@ init([DefaultVHost]) -> name = ?LOG_EXCH_NAME}}. terminate(_Arg, _State) -> - terminated_ok. + ok. code_change(_OldVsn, State, _Extra) -> {ok, State}. @@ -105,10 +105,11 @@ publish1(RoutingKey, Format, Data, LogExch) -> Args = [truncate:term(A, ?LOG_TRUNC) || A <- Data], Headers = [{<<"node">>, longstr, list_to_binary(atom_to_list(node()))}], - {ok, _DeliveredQPids} = - rabbit_basic:publish(LogExch, RoutingKey, - #'P_basic'{content_type = <<"text/plain">>, - timestamp = Timestamp, - headers = Headers}, - list_to_binary(io_lib:format(Format, Args))), - ok. + case rabbit_basic:publish(LogExch, RoutingKey, + #'P_basic'{content_type = <<"text/plain">>, + timestamp = Timestamp, + headers = Headers}, + list_to_binary(io_lib:format(Format, Args))) of + {ok, _QPids} -> ok; + {error, _Err} -> ok + end. |
