diff --git a/deps/rabbit/src/rabbit_amqqueue_process.erl b/deps/rabbit/src/rabbit_amqqueue_process.erl index 63f886bd376..097cf6dde67 100644 --- a/deps/rabbit/src/rabbit_amqqueue_process.erl +++ b/deps/rabbit/src/rabbit_amqqueue_process.erl @@ -725,13 +725,26 @@ maybe_deliver_or_enqueue(Delivery = #delivery{message = Message}, {IsDuplicate, BQS1} = BQ:is_duplicate(Message, BQS), State1 = State#q{backing_queue_state = BQS1}, case IsDuplicate of - true -> State1; - {true, drop} -> State1; - %% Drop publish and nack to publisher - {true, reject} -> + true -> + %% Publish to DLX + _ = with_dlx( + DLX, + fun (X) -> + rabbit_global_counters:messages_dead_lettered(maxlen, + rabbit_classic_queue, + at_most_once, 1), + QName = qname(State1), + rabbit_dead_letter:publish(Message, maxlen, X, RK, QName) + end, + fun () -> + rabbit_global_counters:messages_dead_lettered(maxlen, + rabbit_classic_queue, + disabled, 1) + end), + %% Drop publish and nack to publisher send_reject_publish(Delivery, State1); - %% Enqueue and maybe drop head later false -> + %% Enqueue and maybe drop head later deliver_or_enqueue(Delivery, Delivered, State1) end end. diff --git a/deps/rabbit/src/rabbit_backing_queue.erl b/deps/rabbit/src/rabbit_backing_queue.erl index ffa0a791f1b..3169cbf87bf 100644 --- a/deps/rabbit/src/rabbit_backing_queue.erl +++ b/deps/rabbit/src/rabbit_backing_queue.erl @@ -220,9 +220,8 @@ %% Called prior to a publish or publish_delivered call. Allows the BQ %% to signal that it's already seen this message, (e.g. it was published -%% or discarded previously) specifying whether to drop the message or reject it. --callback is_duplicate(mc:state(), state()) - -> {{true, drop} | {true, reject} | boolean(), state()}. +%% or discarded previously). +-callback is_duplicate(mc:state(), state()) -> {boolean(), state()}. -callback set_queue_mode(queue_mode(), state()) -> state().