@@ -131,10 +131,10 @@ init_source(State = #{source := #{queue := QName0,
131
131
vhost := VHost } = Current } = Src ,
132
132
name := Name ,
133
133
ack_mode := AckMode }) ->
134
- % % Should it just use v2 ?
134
+ % % TODO put this shovel behind the rabbitmq_4.0.0 feature flag
135
135
Mode = case rabbit_feature_flags :is_enabled ('rabbitmq_4.0.0' ) of
136
136
true ->
137
- {credited , Prefetch };
137
+ {credited , ? INITIAL_DELIVERY_COUNT };
138
138
false ->
139
139
{credited , credit_api_v1 }
140
140
end ,
@@ -152,7 +152,7 @@ init_source(State = #{source := #{queue := QName0,
152
152
channel_pid => self (),
153
153
limiter_pid => none ,
154
154
limiter_active => false ,
155
- mode => Mode , % %{simple_prefetch, Prefetch},
155
+ mode => Mode ,
156
156
consumer_tag => CTag ,
157
157
exclusive_consume => false ,
158
158
args => Args ,
@@ -168,10 +168,11 @@ init_source(State = #{source := #{queue := QName0,
168
168
{Remaining , {ok , QState1 }} ->
169
169
{ok , QState , Actions } = rabbit_queue_type :credit (QName , CTag , ? INITIAL_DELIVERY_COUNT , Prefetch , false , QState1 ),
170
170
% % TODO handle actions
171
- State #{source => Src #{current => Current #{queue_states => QState ,
172
- consumer_tag => CTag },
173
- remaining => Remaining ,
174
- remaining_unacked => Remaining }};
171
+ State2 = State #{source => Src #{current => Current #{queue_states => QState ,
172
+ consumer_tag => CTag },
173
+ remaining => Remaining ,
174
+ remaining_unacked => Remaining }},
175
+ handle_queue_actions (Actions , State2 );
175
176
{0 , {error , autodelete }} ->
176
177
exit ({shutdown , autodelete });
177
178
{_Remaining , {error , Reason }} ->
@@ -262,12 +263,6 @@ close_source(_) ->
262
263
% % No consumer tag, no consumer to cancel
263
264
ok .
264
265
265
- handle_source (# 'basic.ack' {delivery_tag = Seq , multiple = Multiple },
266
- State = #{ack_mode := on_confirm }) ->
267
- confirm_to_inbound (fun (Tag , Multi , StateX ) ->
268
- rabbit_shovel_behaviour :ack (Tag , Multi , StateX )
269
- end , Seq , Multiple , State );
270
-
271
266
handle_source ({queue_event , # resource {name = Queue ,
272
267
kind = queue ,
273
268
virtual_host = VHost } = QRef , Evt },
@@ -413,8 +408,10 @@ handle_queue_actions(Actions, State) ->
413
408
lists :foldl (
414
409
fun ({deliver , _CTag , AckRequired , Msgs }, S0 ) ->
415
410
handle_deliver (AckRequired , Msgs , S0 );
416
- (_ , _ ) ->
417
- not_handled
411
+ (Action , S0 ) ->
412
+ % % TODO handle credit_reply
413
+ rabbit_log :warning (" ACTION NOT HANDLED ~p " , [Action ]),
414
+ S0
418
415
% % ({queue_down, QRef}, S0) ->
419
416
% % State;
420
417
% % ({block, QName}, S0) ->
@@ -563,9 +560,9 @@ settle(Op, DeliveryTag, Multiple, #{unacked_message_q := UAMQ0,
563
560
MsgIds = [Ack # pending_ack .msg_id || Ack <- Acked ],
564
561
case rabbit_queue_type :settle (QRef , Op , CTag , MsgIds , QState0 ) of
565
562
{ok , QState1 , Actions } ->
566
- QState = handle_queue_actions ( Actions , QState1 ) ,
567
- State #{ source => Src #{ current => Current #{ queue_states => QState } },
568
- unacked_message_q => UAMQ } ;
563
+ State #{ source => Src #{ current => Current #{ queue_states => QState1 }} ,
564
+ unacked_message_q => UAMQ },
565
+ handle_queue_actions ( Actions , State ) ;
569
566
{'protocol_error' , Type , Reason , Args } ->
570
567
rabbit_log :error (" Shovel failed to settle ~p acknowledgments with ~tp : ~tp " ,
571
568
[Op , Type , io_lib :format (Reason , Args )]),
0 commit comments