Skip to content

Commit 4921739

Browse files
ansdmergify[bot]
authored andcommitted
Avoid warning of unhandled message
Prior to this commit: 1. Start RabbitMQ with MQTT plugin enabled. 2. ``` rabbitmq-diagnostics consume_event_stream ^C ``` 3. The logs will print the following warning: ``` [warning] <0.570.0> ** Undefined handle_info in rabbit_mqtt_internal_event_handler [warning] <0.570.0> ** Unhandled message: {'DOWN',#Ref<0.2410135134.1846280193.145044>,process, [warning] <0.570.0> <52723.100.0>,noconnection} [warning] <0.570.0> ``` This is because rabbit_event_consumer:init/1 monitors the CLI process. Any rabbit_event handler should therefore implement handle_info/2. It's similar to what's described in the gen_event docs about add_sup_handler/3: > Any event handler attached to an event manager which in turn has a > supervised handler should expect callbacks of the shape > Module:handle_info({'EXIT', Pid, Reason}, State). (cherry picked from commit 5b18e9d)
1 parent 0a715ca commit 4921739

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

deps/rabbitmq_mqtt/src/rabbit_mqtt_internal_event_handler.erl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
-behaviour(gen_event).
1111

12-
-export([init/1, handle_event/2, handle_call/2]).
12+
-export([init/1, handle_event/2, handle_call/2, handle_info/2]).
1313

1414
-import(rabbit_misc, [pget/2]).
1515

@@ -36,3 +36,6 @@ handle_event(_Event, ?STATE) ->
3636

3737
handle_call(_Request, ?STATE) ->
3838
{ok, ok, ?STATE}.
39+
40+
handle_info(_Info, State) ->
41+
{ok, State}.

0 commit comments

Comments
 (0)