@@ -905,16 +905,32 @@ ack(AckTags, ChPid, State) ->
905905 State1 # q {backing_queue_state = BQS1 }
906906 end ).
907907
908- requeue (AckTags , ChPid , State ) ->
908+ requeue (AckTags , DelFailed , ChPid , State ) ->
909909 subtract_acks (ChPid , AckTags , State ,
910- fun (State1 ) -> requeue_and_run (AckTags , false , State1 ) end ).
910+ fun (State1 ) -> requeue_and_run (AckTags , DelFailed , false , State1 ) end ).
911+
912+ discard (AckTags , DelFailed , ChPid , State ) ->
913+ with_dlx (
914+ State # q .dlx ,
915+ fun (X ) -> subtract_acks (ChPid , AckTags , State ,
916+ fun (State1 ) ->
917+ dead_letter_rejected_msgs (
918+ AckTags , DelFailed , X , State1 )
919+ end ) end ,
920+ fun () -> rabbit_global_counters :messages_dead_lettered (rejected , rabbit_classic_queue ,
921+ disabled , length (AckTags )),
922+ ack (AckTags , ChPid , State ) end ).
923+
924+ requeue_and_run (AckTags , ActiveConsumersChanged , State ) ->
925+ requeue_and_run (AckTags , true , ActiveConsumersChanged , State ).
911926
912927requeue_and_run (AckTags ,
928+ DelFailed ,
913929 ActiveConsumersChanged ,
914930 # q {backing_queue = BQ ,
915931 backing_queue_state = BQS0 } = State0 ) ->
916932 WasEmpty = BQ :is_empty (BQS0 ),
917- {_MsgIds , BQS } = BQ :requeue (AckTags , BQS0 ),
933+ {_MsgIds , BQS } = BQ :requeue (AckTags , DelFailed , BQS0 ),
918934 State1 = State0 # q {backing_queue_state = BQS },
919935 {_Dropped , State2 } = maybe_drop_head (State1 ),
920936 State3 = drop_expired_msgs (State2 ),
@@ -1079,11 +1095,11 @@ dead_letter_expired_msgs(ExpirePred, X, State = #q{backing_queue = BQ}) ->
10791095 BQ :fetchwhile (ExpirePred , DLFun , Acc , BQS1 )
10801096 end , expired , X , State ).
10811097
1082- dead_letter_rejected_msgs (AckTags , X , State = # q {backing_queue = BQ }) ->
1098+ dead_letter_rejected_msgs (AckTags , DelFailed , X , State = # q {backing_queue = BQ }) ->
10831099 {ok , State1 } =
10841100 dead_letter_msgs (
10851101 fun (DLFun , Acc , BQS ) ->
1086- {Acc1 , BQS1 } = BQ :ackfold (DLFun , Acc , BQS , AckTags ),
1102+ {Acc1 , BQS1 } = BQ :ackfold (DLFun , Acc , BQS , AckTags , DelFailed ),
10871103 {ok , Acc1 , BQS1 }
10881104 end , rejected , X , State ),
10891105 State1 .
@@ -1258,7 +1274,8 @@ prioritise_cast(Msg, _Len, State) ->
12581274 delete_immediately -> 8 ;
12591275 {delete_exclusive , _Pid } -> 8 ;
12601276 {run_backing_queue , _Mod , _Fun } -> 6 ;
1261- {ack , _AckTags , _ChPid } -> 4 ; % % [1]
1277+ {ack , _AckTags , _ChPid } -> 4 ; % % [1] %% @todo Remove when 'rabbitmq_4.3.0' FF is required.
1278+ {complete , _AckTags , _ChPid } -> 4 ; % % [1]
12621279 {resume , _ChPid } -> 3 ;
12631280 {notify_sent , _ChPid , _Credit } -> consumer_bias (State , 0 , 2 );
12641281 _ -> 0
@@ -1527,23 +1544,28 @@ handle_cast({deliver,
15271544 State1 = State # q {senders = Senders1 },
15281545 noreply (maybe_deliver_or_enqueue (Delivery , Delivered , State1 ));
15291546
1547+ % % Compat for RabbitMQ 4.2. @todo Remove when 'rabbitmq_4.3.0' FF is required.
15301548handle_cast ({ack , AckTags , ChPid }, State ) ->
1549+ handle_cast ({complete , AckTags , ChPid }, State );
1550+ handle_cast ({reject , true , AckTags , ChPid }, State ) ->
1551+ handle_cast ({requeue , AckTags , ChPid }, State );
1552+ handle_cast ({reject , false , AckTags , ChPid }, State ) ->
1553+ handle_cast ({discard , AckTags , ChPid }, State );
1554+
1555+ handle_cast ({complete , AckTags , ChPid }, State ) ->
15311556 noreply (ack (AckTags , ChPid , State ));
15321557
1533- handle_cast ({reject , true , AckTags , ChPid }, State ) ->
1534- noreply (requeue (AckTags , ChPid , State ));
1558+ handle_cast ({requeue , AckTags , ChPid }, State ) ->
1559+ noreply (requeue (AckTags , false , ChPid , State ));
15351560
1536- handle_cast ({reject , false , AckTags , ChPid }, State ) ->
1537- noreply (with_dlx (
1538- State # q .dlx ,
1539- fun (X ) -> subtract_acks (ChPid , AckTags , State ,
1540- fun (State1 ) ->
1541- dead_letter_rejected_msgs (
1542- AckTags , X , State1 )
1543- end ) end ,
1544- fun () -> rabbit_global_counters :messages_dead_lettered (rejected , rabbit_classic_queue ,
1545- disabled , length (AckTags )),
1546- ack (AckTags , ChPid , State ) end ));
1561+ handle_cast ({discard , AckTags , ChPid }, State ) ->
1562+ noreply (discard (AckTags , true , ChPid , State ));
1563+
1564+ handle_cast ({modify , AckTags , DelFailed , false , _Anns , ChPid }, State ) ->
1565+ noreply (requeue (AckTags , DelFailed , ChPid , State ));
1566+
1567+ handle_cast ({modify , AckTags , DelFailed , true , _Anns , ChPid }, State ) ->
1568+ noreply (discard (AckTags , DelFailed , ChPid , State ));
15471569
15481570handle_cast ({delete_exclusive , ConnPid }, State ) ->
15491571 log_delete_exclusive (ConnPid , State ),
0 commit comments