Skip to content

Commit

Permalink
Merge pull request #9721 from rabbitmq/mergify/bp/v3.11.x/pr-9720
Browse files Browse the repository at this point in the history
Actually nack when using 'Nack message requeue true' (backport #9715) (backport #9720)
  • Loading branch information
michaelklishin authored Oct 17, 2023
2 parents 05db76e + 49168c9 commit a01b6a7
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions deps/rabbitmq_management/src/rabbit_mgmt_wm_queue_get.erl
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ do_it(ReqData0, Context) ->
end,

Reply = basic_gets(Count, Ch, Q, AckMode, Enc, Trunc),
maybe_rejects(Reply, Ch, AckMode),
maybe_return(Reply, Ch, AckMode),
rabbit_mgmt_util:reply(remove_delivery_tag(Reply),
ReqData, Context)
end)
Expand Down Expand Up @@ -96,11 +96,11 @@ parse_ackmode(reject_requeue_true) -> false.
% the messages must rejects later,
% because we get always the same message if the
% messages are requeued inside basic_get/5
maybe_rejects(R, Ch, AckMode) ->
maybe_return(R, Ch, AckMode) ->
lists:foreach(fun(X) ->
maybe_reject(Ch, AckMode,
proplists:get_value(delivery_tag, X))
end, R).
maybe_reject_or_nack(Ch, AckMode,
proplists:get_value(delivery_tag, X))
end, R).

% removes the delivery_tag from the reply.
% it is not necessary
Expand All @@ -109,12 +109,18 @@ remove_delivery_tag([H|T]) ->
[proplists:delete(delivery_tag, H) | [X || X <- remove_delivery_tag(T)]].


maybe_reject(Ch, AckMode, DeliveryTag) when AckMode == reject_requeue_true;
AckMode == reject_requeue_false ->
maybe_reject_or_nack(Ch, AckMode, DeliveryTag)
when AckMode == reject_requeue_true;
AckMode == reject_requeue_false ->
amqp_channel:call(Ch,
#'basic.reject'{delivery_tag = DeliveryTag,
requeue = ackmode_to_requeue(AckMode)});
maybe_reject(_Ch, _AckMode, _DeliveryTag) -> ok.
#'basic.reject'{delivery_tag = DeliveryTag,
requeue = ackmode_to_requeue(AckMode)});
maybe_reject_or_nack(Ch, ack_requeue_true, DeliveryTag) ->
amqp_channel:call(Ch,
#'basic.nack'{delivery_tag = DeliveryTag,
multiple = false,
requeue = true});
maybe_reject_or_nack(_Ch, _AckMode, _DeliveryTag) -> ok.


basic_get(Ch, Q, AckMode, Enc, Trunc) ->
Expand Down

0 comments on commit a01b6a7

Please sign in to comment.