diff --git a/deps/rabbit/src/rabbit_amqqueue_process.erl b/deps/rabbit/src/rabbit_amqqueue_process.erl index 920584ca8ee2..222ec73f52e8 100644 --- a/deps/rabbit/src/rabbit_amqqueue_process.erl +++ b/deps/rabbit/src/rabbit_amqqueue_process.erl @@ -815,15 +815,27 @@ send_reject_publish(#delivery{confirm = true, backing_queue = BQ, backing_queue_state = BQS, msg_id_to_channel = MTC}) -> + %% Drop publish and nack to publisher ok = rabbit_classic_queue:send_rejection(SenderPid, amqqueue:get_name(Q), MsgSeqNo), MTC1 = maps:remove(MsgId, MTC), BQS1 = BQ:discard(MsgId, SenderPid, Flow, BQS), State#q{ backing_queue_state = BQS1, msg_id_to_channel = MTC1 }; -send_reject_publish(#delivery{confirm = false}, - _Delivered, State) -> - State. +send_reject_publish(#delivery{confirm = false, + sender = SenderPid, + flow = Flow, + message = Msg}, + _Delivered, + State = #q{q = Q, + backing_queue = BQ, + backing_queue_state = BQS, + msg_id_to_channel = MTC}) -> + %% Only drop publish + MsgId = mc:get_annotation(id, Msg), + MTC1 = maps:remove(MsgId, MTC), + BQS1 = BQ:discard(MsgId, SenderPid, Flow, BQS), + State#q{ backing_queue_state = BQS1, msg_id_to_channel = MTC1 }. will_overflow(_, #q{max_length = undefined, max_bytes = undefined}) -> false;