Skip to content

Commit 0950a8f

Browse files
committed
Local shovels: set link credit
1 parent 90d6171 commit 0950a8f

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

deps/rabbitmq_shovel/src/rabbit_local_shovel.erl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
%% sequence number initialized at an arbitrary point by the sender."
5252
%% See rabbit_amqp_session.erl
5353
-define(INITIAL_DELIVERY_COUNT, 16#ff_ff_ff_ff - 4).
54+
-define(DEFAULT_MAX_LINK_CREDIT, 170).
5455

5556
-record(pending_ack, {
5657
delivery_tag,
@@ -125,7 +126,6 @@ connect_dest(State = #{dest := Dest = #{resource_decl := {M, F, MFArgs},
125126
end.
126127

127128
init_source(State = #{source := #{queue := QName0,
128-
prefetch_count := Prefetch,
129129
consumer_args := Args,
130130
current := #{queue_states := QState0,
131131
vhost := VHost} = Current} = Src,
@@ -138,6 +138,8 @@ init_source(State = #{source := #{queue := QName0,
138138
false ->
139139
{credited, credit_api_v1}
140140
end,
141+
MaxLinkCredit = application:get_env(
142+
rabbit, max_link_credit, ?DEFAULT_MAX_LINK_CREDIT),
141143
QName = rabbit_misc:r(VHost, queue, QName0),
142144
CTag = consumer_tag(Name),
143145
case rabbit_amqqueue:with(
@@ -166,7 +168,7 @@ init_source(State = #{source := #{queue := QName0,
166168
end
167169
end) of
168170
{Remaining, {ok, QState1}} ->
169-
{ok, QState, Actions} = rabbit_queue_type:credit(QName, CTag, ?INITIAL_DELIVERY_COUNT, Prefetch, false, QState1),
171+
{ok, QState, Actions} = rabbit_queue_type:credit(QName, CTag, ?INITIAL_DELIVERY_COUNT, MaxLinkCredit, false, QState1),
170172
%% TODO handle actions
171173
State2 = State#{source => Src#{current => Current#{queue_states => QState,
172174
consumer_tag => CTag},

0 commit comments

Comments
 (0)