Просмотр исходного кода

fix(cluster link): handle async query results

Before this fix, if `{error, ecpool_empty}` was returned, it was classified as an
unrecoverable error, and the message would be lost.

Also, currently, in such situation ecpool pool will stay empty, because there's no
`auto_reconnect` option being set when starting it.
Thales Macedo Garitezi 1 год назад
Родитель
Сommit
d6724766be
1 измененных файлов с 5 добавлено и 2 удалено
  1. 5 2
      apps/emqx_cluster_link/src/emqx_cluster_link_mqtt.erl

+ 5 - 2
apps/emqx_cluster_link/src/emqx_cluster_link_mqtt.erl

@@ -211,7 +211,7 @@ on_query_async(
     Callback = {fun on_async_result/2, [CallbackIn]},
     #message{topic = Topic, qos = QoS} = FwdMsg,
     %% TODO check message ordering, pick by topic,client pair?
-    ecpool:pick_and_do(
+    Result = ecpool:pick_and_do(
         {PoolName, Topic},
         fun(ConnPid) ->
             %% #delivery{} record has no valuable data for a remote link...
@@ -226,7 +226,10 @@ on_query_async(
             PubResult
         end,
         no_handover
-    ).
+    ),
+    %% This result could be `{error, ecpool_empty}', for example, which should be
+    %% recoverable.  If we didn't handle it here, it would be considered unrecoverable.
+    handle_send_result(Result).
 
 %% copied from emqx_bridge_mqtt_connector