Fix the massages order when batch dispatching
This commit is contained in:
parent
22f7280d8e
commit
0b116bc208
|
@ -798,7 +798,7 @@ handle_dispatch(Msgs, State = #state{inflight = Inflight,
|
|||
subscriptions = SubMap}) ->
|
||||
SessProps = #{client_id => ClientId, username => Username},
|
||||
%% Drain the mailbox and batch deliver
|
||||
Msgs1 = drain_m(batch_n(Inflight), Msgs),
|
||||
Msgs1 = Msgs ++ drain_m(batch_n(Inflight)),
|
||||
%% Ack the messages for shared subscription
|
||||
Msgs2 = maybe_ack_shared(Msgs1, State),
|
||||
%% Process suboptions
|
||||
|
@ -821,6 +821,9 @@ batch_n(Inflight) ->
|
|||
Sz -> Sz - emqx_inflight:size(Inflight)
|
||||
end.
|
||||
|
||||
drain_m(Cnt) ->
|
||||
drain_m(Cnt, []).
|
||||
|
||||
drain_m(Cnt, Msgs) when Cnt =< 0 ->
|
||||
lists:reverse(Msgs);
|
||||
drain_m(Cnt, Msgs) ->
|
||||
|
|
Loading…
Reference in New Issue