169
169
delivery_flow ,
170
170
interceptor_state ,
171
171
queue_states ,
172
- queue_cleanup_timer
172
+ tick_timer
173
173
}).
174
174
175
175
-define (QUEUE , lqueue ).
@@ -489,7 +489,6 @@ init([Channel, ReaderPid, WriterPid, ConnPid, ConnName, Protocol, User, VHost,
489
489
end ,
490
490
MaxMessageSize = get_max_message_size (),
491
491
ConsumerTimeout = get_consumer_timeout (),
492
- rabbit_log :info (" consumer timeout ~w " , [ConsumerTimeout ]),
493
492
State = # ch {cfg = # conf {state = starting ,
494
493
protocol = Protocol ,
495
494
channel = Channel ,
@@ -535,7 +534,7 @@ init([Channel, ReaderPid, WriterPid, ConnPid, ConnName, Protocol, User, VHost,
535
534
rabbit_event :if_enabled (State2 , # ch .stats_timer ,
536
535
fun () -> emit_stats (State2 ) end ),
537
536
put_operation_timeout (),
538
- State3 = init_queue_cleanup_timer (State2 ),
537
+ State3 = init_tick_timer (State2 ),
539
538
{ok , State3 , hibernate ,
540
539
{backoff , ? HIBERNATE_AFTER_MIN , ? HIBERNATE_AFTER_MIN , ? DESIRED_HIBERNATE }}.
541
540
@@ -828,12 +827,13 @@ handle_info({{Ref, Node}, LateAnswer},
828
827
[Channel , LateAnswer , Node ]),
829
828
noreply (State );
830
829
831
- handle_info (queue_cleanup , State0 = # ch {cfg = # conf {channel = Channel ,
832
- consumer_timeout = Timeout },
833
- queue_states = QueueStates0 ,
834
- queue_names = QNames ,
835
- queue_consumers = QCons ,
836
- unacked_message_q = UAMQ }) ->
830
+ handle_info (tick , State0 = # ch {cfg = # conf {channel = Channel ,
831
+ capabilities = Capabilities ,
832
+ consumer_timeout = Timeout },
833
+ queue_states = QueueStates0 ,
834
+ queue_names = QNames ,
835
+ queue_consumers = QCons ,
836
+ unacked_message_q = UAMQ }) ->
837
837
QueueStates1 =
838
838
maps :filter (fun (_ , QS ) ->
839
839
QName = rabbit_quorum_queue :queue_name (QS ),
@@ -845,22 +845,24 @@ handle_info(queue_cleanup, State0 = #ch{cfg = #conf{channel = Channel,
845
845
{value , {_DTag , ConsumerTag , Time , {QPid , _Msg }}}
846
846
when is_integer (Timeout )
847
847
andalso Time < Now - Timeout ->
848
- case ConsumerTag of
849
- _ when is_integer (ConsumerTag ) ->
850
- % % basic.get - there is no mechanims so we just crash the
851
- % % channel
848
+ rabbit_log_channel :info (" Consumer ~w on Channel ~w has timed out "
849
+ " waiting on ack" ,
850
+ [rabbit_data_coercion :to_binary (ConsumerTag ),
851
+ Channel ]),
852
+ SupportsCancel = case rabbit_misc :table_lookup (
853
+ Capabilities ,
854
+ <<" consumer_cancel_notify" >>) of
855
+ {bool , true } when is_binary (ConsumerTag ) ->
856
+ true ;
857
+ _ -> false
858
+ end ,
859
+ case SupportsCancel of
860
+ false ->
852
861
Ex = rabbit_misc :amqp_error (precondition_failed ,
853
- " basic.get ack timed out on channel ~w " ,
862
+ " consumer ack timed out on channel ~w " ,
854
863
[Channel ], none ),
855
864
handle_exception (Ex , State0 );
856
- % rabbit_misc:protocol_error(precondition_failed,
857
- % "basic.get ack timed out on channel ~w ",
858
- % [Channel]);
859
- _ ->
860
- rabbit_log_channel :info (" Consumer ~w on Channel ~w has timed out "
861
- " waiting on ack" ,
862
- [rabbit_data_coercion :to_binary (ConsumerTag ),
863
- Channel ]),
865
+ true ->
864
866
QRef = qpid_to_ref (QPid ),
865
867
QName = maps :get (QRef , QNames ),
866
868
% % cancel the consumer with the client
@@ -881,15 +883,14 @@ handle_info(queue_cleanup, State0 = #ch{cfg = #conf{channel = Channel,
881
883
? QUEUE :to_list (UAMQ )),
882
884
QueueStates = rabbit_amqqueue :requeue (QPid , {ConsumerTag , MsgIds },
883
885
self (), QueueStates2 ),
884
-
885
886
State = State1 # ch {queue_states = QueueStates ,
886
887
queue_consumers = maps :remove (QRef , QCons ),
887
888
unacked_message_q = Rem },
888
- noreply (init_queue_cleanup_timer (State ))
889
+ noreply (init_tick_timer (State ))
889
890
end ;
890
891
_ ->
891
892
noreply (
892
- init_queue_cleanup_timer (
893
+ init_tick_timer (
893
894
State0 # ch {queue_states = QueueStates1 }))
894
895
end ;
895
896
handle_info ({channel_source , Source }, State = # ch {cfg = Cfg }) ->
@@ -1910,10 +1911,7 @@ cancel_consumer(CTag, QName,
1910
1911
consumer_mapping = CMap }) ->
1911
1912
case rabbit_misc :table_lookup (
1912
1913
Capabilities , <<" consumer_cancel_notify" >>) of
1913
- {bool , true } -> ok =
1914
-
1915
- rabbit_log :info (" Consumer cancel notify suppoerted ~w " , [CTag ]),
1916
- send (# 'basic.cancel' {consumer_tag = CTag ,
1914
+ {bool , true } -> ok = send (# 'basic.cancel' {consumer_tag = CTag ,
1917
1915
nowait = true }, State );
1918
1916
_ -> ok
1919
1917
end ,
@@ -2692,9 +2690,9 @@ handle_basic_get(WriterPid, DeliveryTag, NoAck, MessageCount,
2692
2690
State1 = track_delivering_queue (NoAck , QPid , QName , State ),
2693
2691
{noreply , record_sent (get , DeliveryTag , not (NoAck ), Msg , State1 )}.
2694
2692
2695
- init_queue_cleanup_timer (State ) ->
2696
- {ok , Interval } = application :get_env (rabbit , channel_queue_cleanup_interval ),
2697
- State # ch {queue_cleanup_timer = erlang :send_after (Interval , self (), queue_cleanup )}.
2693
+ init_tick_timer (State ) ->
2694
+ {ok , Interval } = application :get_env (rabbit , channel_tick_interval ),
2695
+ State # ch {tick_timer = erlang :send_after (Interval , self (), tick )}.
2698
2696
2699
2697
% % only classic queues need monitoring so rather than special casing
2700
2698
% % everywhere monitors are set up we wrap it here for this module
0 commit comments