33
33
import static org .mockito .Mockito .verify ;
34
34
import static org .mockito .Mockito .when ;
35
35
36
- import com .rabbitmq .stream .BackOffDelayPolicy ;
37
- import com .rabbitmq .stream .Constants ;
38
- import com .rabbitmq .stream .OffsetSpecification ;
39
- import com .rabbitmq .stream .StreamDoesNotExistException ;
40
- import com .rabbitmq .stream .StreamException ;
41
- import com .rabbitmq .stream .SubscriptionListener ;
36
+ import com .rabbitmq .stream .*;
42
37
import com .rabbitmq .stream .codec .WrapperMessageBuilder ;
43
38
import com .rabbitmq .stream .impl .Client .MessageListener ;
44
39
import com .rabbitmq .stream .impl .Client .QueryOffsetResponse ;
@@ -76,8 +71,7 @@ public class ConsumersCoordinatorTest {
76
71
77
72
private static final SubscriptionListener NO_OP_SUBSCRIPTION_LISTENER = subscriptionContext -> {};
78
73
private static final Runnable NO_OP_TRACKING_CLOSING_CALLBACK = () -> {};
79
- private int initialCredits = 10 ;
80
- private int additionalCredits = 1 ;
74
+ private final int initialCredits = 10 ;
81
75
82
76
@ Mock StreamEnvironment environment ;
83
77
@ Mock StreamConsumer consumer ;
@@ -205,7 +199,7 @@ void tearDown() throws Exception {
205
199
NO_OP_SUBSCRIPTION_LISTENER ,
206
200
NO_OP_TRACKING_CLOSING_CALLBACK ,
207
201
(offset , message ) -> {},
208
- null ,
202
+ LegacyFlowControlStrategyBuilderFactory . INSTANCE . builder ( null ) ,
209
203
Collections .emptyMap (),
210
204
initialCredits );
211
205
verify (clientFactory , times (2 )).client (any ());
@@ -247,7 +241,7 @@ void shouldGetExactNodeImmediatelyWithAdvertisedHostNameClientFactoryAndExactNod
247
241
NO_OP_SUBSCRIPTION_LISTENER ,
248
242
NO_OP_TRACKING_CLOSING_CALLBACK ,
249
243
(offset , message ) -> {},
250
- null ,
244
+ LegacyFlowControlStrategyBuilderFactory . INSTANCE . builder ( null ) ,
251
245
Collections .emptyMap (),
252
246
initialCredits );
253
247
verify (clientFactory , times (1 )).client (any ());
@@ -278,7 +272,7 @@ void shouldSubscribeWithEmptyPropertiesWithUnamedConsumer() {
278
272
NO_OP_SUBSCRIPTION_LISTENER ,
279
273
NO_OP_TRACKING_CLOSING_CALLBACK ,
280
274
(offset , message ) -> {},
281
- null ,
275
+ LegacyFlowControlStrategyBuilderFactory . INSTANCE . builder ( null ) ,
282
276
Collections .emptyMap (),
283
277
initialCredits );
284
278
verify (clientFactory , times (1 )).client (any ());
@@ -300,7 +294,7 @@ void subscribeShouldThrowExceptionWhenNoMetadataForTheStream() {
300
294
NO_OP_SUBSCRIPTION_LISTENER ,
301
295
NO_OP_TRACKING_CLOSING_CALLBACK ,
302
296
(offset , message ) -> {},
303
- null ,
297
+ LegacyFlowControlStrategyBuilderFactory . INSTANCE . builder ( null ) ,
304
298
Collections .emptyMap (),
305
299
initialCredits ))
306
300
.isInstanceOf (StreamDoesNotExistException .class );
@@ -320,7 +314,7 @@ void subscribeShouldThrowExceptionWhenStreamDoesNotExist() {
320
314
NO_OP_SUBSCRIPTION_LISTENER ,
321
315
NO_OP_TRACKING_CLOSING_CALLBACK ,
322
316
(offset , message ) -> {},
323
- null ,
317
+ LegacyFlowControlStrategyBuilderFactory . INSTANCE . builder ( null ) ,
324
318
Collections .emptyMap (),
325
319
initialCredits ))
326
320
.isInstanceOf (StreamDoesNotExistException .class );
@@ -350,7 +344,7 @@ void subscribePropagateExceptionWhenClientSubscriptionFails() {
350
344
NO_OP_SUBSCRIPTION_LISTENER ,
351
345
NO_OP_TRACKING_CLOSING_CALLBACK ,
352
346
(offset , message ) -> {},
353
- null ,
347
+ LegacyFlowControlStrategyBuilderFactory . INSTANCE . builder ( null ) ,
354
348
Collections .emptyMap (),
355
349
initialCredits ))
356
350
.isInstanceOf (StreamException .class )
@@ -372,7 +366,7 @@ void subscribeShouldThrowExceptionWhenMetadataResponseIsNotOk() {
372
366
NO_OP_SUBSCRIPTION_LISTENER ,
373
367
NO_OP_TRACKING_CLOSING_CALLBACK ,
374
368
(offset , message ) -> {},
375
- null ,
369
+ LegacyFlowControlStrategyBuilderFactory . INSTANCE . builder ( null ) ,
376
370
Collections .emptyMap (),
377
371
initialCredits ))
378
372
.isInstanceOf (IllegalStateException .class );
@@ -391,7 +385,7 @@ void subscribeShouldThrowExceptionIfNoNodeAvailableForStream() {
391
385
NO_OP_SUBSCRIPTION_LISTENER ,
392
386
NO_OP_TRACKING_CLOSING_CALLBACK ,
393
387
(offset , message ) -> {},
394
- null ,
388
+ LegacyFlowControlStrategyBuilderFactory . INSTANCE . builder ( null ) ,
395
389
Collections .emptyMap (),
396
390
initialCredits ))
397
391
.isInstanceOf (IllegalStateException .class );
@@ -433,7 +427,7 @@ void subscribeShouldSubscribeToStreamAndDispatchMessage_UnsubscribeShouldUnsubsc
433
427
NO_OP_SUBSCRIPTION_LISTENER ,
434
428
() -> trackingClosingCallbackCalls .incrementAndGet (),
435
429
(offset , message ) -> messageHandlerCalls .incrementAndGet (),
436
- null ,
430
+ LegacyFlowControlStrategyBuilderFactory . INSTANCE . builder ( null ) ,
437
431
Collections .emptyMap (),
438
432
initialCredits );
439
433
verify (clientFactory , times (1 )).client (any ());
@@ -484,7 +478,7 @@ void subscribeShouldSubscribeToStreamAndDispatchMessageWithManySubscriptions() {
484
478
NO_OP_TRACKING_CLOSING_CALLBACK ,
485
479
(offset , message ) ->
486
480
messageHandlerCalls .compute (subId , (k , v ) -> (v == null ) ? 1 : ++v ),
487
- null ,
481
+ LegacyFlowControlStrategyBuilderFactory . INSTANCE . builder ( null ) ,
488
482
Collections .emptyMap (),
489
483
initialCredits );
490
484
closingRunnables .add (closingRunnable );
@@ -560,7 +554,7 @@ void shouldRedistributeConsumerIfConnectionIsLost() throws Exception {
560
554
NO_OP_SUBSCRIPTION_LISTENER ,
561
555
NO_OP_TRACKING_CLOSING_CALLBACK ,
562
556
(offset , message ) -> messageHandlerCalls .incrementAndGet (),
563
- null ,
557
+ LegacyFlowControlStrategyBuilderFactory . INSTANCE . builder ( null ) ,
564
558
Collections .emptyMap (),
565
559
initialCredits );
566
560
verify (clientFactory , times (1 )).client (any ());
@@ -580,7 +574,7 @@ void shouldRedistributeConsumerIfConnectionIsLost() throws Exception {
580
574
NO_OP_SUBSCRIPTION_LISTENER ,
581
575
NO_OP_TRACKING_CLOSING_CALLBACK ,
582
576
(offset , message ) -> {},
583
- null ,
577
+ LegacyFlowControlStrategyBuilderFactory . INSTANCE . builder ( null ) ,
584
578
Collections .emptyMap (),
585
579
initialCredits );
586
580
@@ -661,7 +655,7 @@ void shouldSkipRecoveryIfRecoveryIsAlreadyInProgress() throws Exception {
661
655
NO_OP_SUBSCRIPTION_LISTENER ,
662
656
NO_OP_TRACKING_CLOSING_CALLBACK ,
663
657
(offset , message ) -> messageHandlerCalls .incrementAndGet (),
664
- null ,
658
+ LegacyFlowControlStrategyBuilderFactory . INSTANCE . builder ( null ) ,
665
659
Collections .emptyMap (),
666
660
initialCredits );
667
661
verify (clientFactory , times (1 )).client (any ());
@@ -717,7 +711,7 @@ void shouldRedistributeConsumerOnMetadataUpdate() throws Exception {
717
711
NO_OP_SUBSCRIPTION_LISTENER ,
718
712
NO_OP_TRACKING_CLOSING_CALLBACK ,
719
713
(offset , message ) -> messageHandlerCalls .incrementAndGet (),
720
- null ,
714
+ LegacyFlowControlStrategyBuilderFactory . INSTANCE . builder ( null ) ,
721
715
Collections .emptyMap (),
722
716
initialCredits );
723
717
verify (clientFactory , times (1 )).client (any ());
@@ -732,7 +726,7 @@ void shouldRedistributeConsumerOnMetadataUpdate() throws Exception {
732
726
NO_OP_SUBSCRIPTION_LISTENER ,
733
727
NO_OP_TRACKING_CLOSING_CALLBACK ,
734
728
(offset , message ) -> {},
735
- null ,
729
+ LegacyFlowControlStrategyBuilderFactory . INSTANCE . builder ( null ) ,
736
730
Collections .emptyMap (),
737
731
initialCredits );
738
732
@@ -821,7 +815,7 @@ void shouldRetryRedistributionIfMetadataIsNotUpdatedImmediately() throws Excepti
821
815
NO_OP_SUBSCRIPTION_LISTENER ,
822
816
NO_OP_TRACKING_CLOSING_CALLBACK ,
823
817
(offset , message ) -> messageHandlerCalls .incrementAndGet (),
824
- null ,
818
+ LegacyFlowControlStrategyBuilderFactory . INSTANCE . builder ( null ) ,
825
819
Collections .emptyMap (),
826
820
initialCredits );
827
821
verify (clientFactory , times (1 )).client (any ());
@@ -887,7 +881,7 @@ void metadataUpdate_shouldCloseConsumerIfStreamIsDeleted() throws Exception {
887
881
NO_OP_SUBSCRIPTION_LISTENER ,
888
882
NO_OP_TRACKING_CLOSING_CALLBACK ,
889
883
(offset , message ) -> messageHandlerCalls .incrementAndGet (),
890
- null ,
884
+ LegacyFlowControlStrategyBuilderFactory . INSTANCE . builder ( null ) ,
891
885
Collections .emptyMap (),
892
886
initialCredits );
893
887
verify (clientFactory , times (1 )).client (any ());
@@ -941,7 +935,7 @@ void metadataUpdate_shouldCloseConsumerIfRetryTimeoutIsReached() throws Exceptio
941
935
NO_OP_SUBSCRIPTION_LISTENER ,
942
936
NO_OP_TRACKING_CLOSING_CALLBACK ,
943
937
(offset , message ) -> messageHandlerCalls .incrementAndGet (),
944
- null ,
938
+ LegacyFlowControlStrategyBuilderFactory . INSTANCE . builder ( null ) ,
945
939
Collections .emptyMap (),
946
940
initialCredits );
947
941
verify (clientFactory , times (1 )).client (any ());
@@ -996,7 +990,7 @@ void shouldUseNewClientsForMoreThanMaxSubscriptionsAndCloseClientAfterUnsubscrip
996
990
NO_OP_SUBSCRIPTION_LISTENER ,
997
991
NO_OP_TRACKING_CLOSING_CALLBACK ,
998
992
(offset , message ) -> {},
999
- null ,
993
+ LegacyFlowControlStrategyBuilderFactory . INSTANCE . builder ( null ) ,
1000
994
Collections .emptyMap (),
1001
995
initialCredits ))
1002
996
.collect (Collectors .toList ());
@@ -1058,7 +1052,7 @@ void shouldRemoveClientSubscriptionManagerFromPoolAfterConnectionDies() throws E
1058
1052
NO_OP_SUBSCRIPTION_LISTENER ,
1059
1053
NO_OP_TRACKING_CLOSING_CALLBACK ,
1060
1054
(offset , message ) -> {},
1061
- null ,
1055
+ LegacyFlowControlStrategyBuilderFactory . INSTANCE . builder ( null ) ,
1062
1056
Collections .emptyMap (),
1063
1057
initialCredits );
1064
1058
});
@@ -1084,7 +1078,7 @@ void shouldRemoveClientSubscriptionManagerFromPoolAfterConnectionDies() throws E
1084
1078
NO_OP_SUBSCRIPTION_LISTENER ,
1085
1079
NO_OP_TRACKING_CLOSING_CALLBACK ,
1086
1080
(offset , message ) -> {},
1087
- null ,
1081
+ LegacyFlowControlStrategyBuilderFactory . INSTANCE . builder ( null ) ,
1088
1082
Collections .emptyMap (),
1089
1083
initialCredits );
1090
1084
@@ -1125,7 +1119,7 @@ void shouldRemoveClientSubscriptionManagerFromPoolIfEmptyAfterMetadataUpdate() t
1125
1119
NO_OP_SUBSCRIPTION_LISTENER ,
1126
1120
NO_OP_TRACKING_CLOSING_CALLBACK ,
1127
1121
(offset , message ) -> {},
1128
- null ,
1122
+ LegacyFlowControlStrategyBuilderFactory . INSTANCE . builder ( null ) ,
1129
1123
Collections .emptyMap (),
1130
1124
initialCredits );
1131
1125
});
@@ -1157,7 +1151,7 @@ void shouldRemoveClientSubscriptionManagerFromPoolIfEmptyAfterMetadataUpdate() t
1157
1151
NO_OP_SUBSCRIPTION_LISTENER ,
1158
1152
NO_OP_TRACKING_CLOSING_CALLBACK ,
1159
1153
(offset , message ) -> {},
1160
- null ,
1154
+ LegacyFlowControlStrategyBuilderFactory . INSTANCE . builder ( null ) ,
1161
1155
Collections .emptyMap (),
1162
1156
initialCredits );
1163
1157
@@ -1208,7 +1202,7 @@ void shouldRestartWhereItLeftOffAfterDisruption(Consumer<ConsumersCoordinatorTes
1208
1202
NO_OP_SUBSCRIPTION_LISTENER ,
1209
1203
NO_OP_TRACKING_CLOSING_CALLBACK ,
1210
1204
(offset , message ) -> {},
1211
- null ,
1205
+ LegacyFlowControlStrategyBuilderFactory . INSTANCE . builder ( null ) ,
1212
1206
Collections .emptyMap (),
1213
1207
initialCredits );
1214
1208
verify (clientFactory , times (1 )).client (any ());
@@ -1281,7 +1275,7 @@ void shouldReUseInitialOffsetSpecificationAfterDisruptionIfNoMessagesReceived(
1281
1275
NO_OP_SUBSCRIPTION_LISTENER ,
1282
1276
NO_OP_TRACKING_CLOSING_CALLBACK ,
1283
1277
(offset , message ) -> {},
1284
- null ,
1278
+ LegacyFlowControlStrategyBuilderFactory . INSTANCE . builder ( null ) ,
1285
1279
Collections .emptyMap (),
1286
1280
initialCredits );
1287
1281
verify (clientFactory , times (1 )).client (any ());
@@ -1356,7 +1350,7 @@ void shouldUseStoredOffsetOnRecovery(Consumer<ConsumersCoordinatorTest> configur
1356
1350
NO_OP_SUBSCRIPTION_LISTENER ,
1357
1351
NO_OP_TRACKING_CLOSING_CALLBACK ,
1358
1352
(offset , message ) -> {},
1359
- null ,
1353
+ LegacyFlowControlStrategyBuilderFactory . INSTANCE . builder ( null ) ,
1360
1354
Collections .emptyMap (),
1361
1355
initialCredits );
1362
1356
verify (clientFactory , times (1 )).client (any ());
@@ -1443,7 +1437,7 @@ void shouldRetryAssignmentOnRecoveryTimeout() throws Exception {
1443
1437
NO_OP_SUBSCRIPTION_LISTENER ,
1444
1438
NO_OP_TRACKING_CLOSING_CALLBACK ,
1445
1439
(offset , message ) -> {},
1446
- null ,
1440
+ LegacyFlowControlStrategyBuilderFactory . INSTANCE . builder ( null ) ,
1447
1441
Collections .emptyMap (),
1448
1442
initialCredits );
1449
1443
verify (clientFactory , times (1 )).client (any ());
@@ -1458,7 +1452,7 @@ void shouldRetryAssignmentOnRecoveryTimeout() throws Exception {
1458
1452
NO_OP_SUBSCRIPTION_LISTENER ,
1459
1453
NO_OP_TRACKING_CLOSING_CALLBACK ,
1460
1454
(offset , message ) -> {},
1461
- null ,
1455
+ LegacyFlowControlStrategyBuilderFactory . INSTANCE . builder ( null ) ,
1462
1456
Collections .emptyMap (),
1463
1457
initialCredits );
1464
1458
verify (clientFactory , times (1 )).client (any ());
@@ -1524,7 +1518,7 @@ void shouldRetryAssignmentOnRecoveryStreamNotAvailableFailure() throws Exception
1524
1518
NO_OP_SUBSCRIPTION_LISTENER ,
1525
1519
NO_OP_TRACKING_CLOSING_CALLBACK ,
1526
1520
(offset , message ) -> {},
1527
- null ,
1521
+ LegacyFlowControlStrategyBuilderFactory . INSTANCE . builder ( null ) ,
1528
1522
Collections .emptyMap (),
1529
1523
initialCredits );
1530
1524
verify (clientFactory , times (1 )).client (any ());
@@ -1590,7 +1584,7 @@ void shouldRetryAssignmentOnRecoveryCandidateLookupFailure() throws Exception {
1590
1584
NO_OP_SUBSCRIPTION_LISTENER ,
1591
1585
NO_OP_TRACKING_CLOSING_CALLBACK ,
1592
1586
(offset , message ) -> {},
1593
- null ,
1587
+ LegacyFlowControlStrategyBuilderFactory . INSTANCE . builder ( null ) ,
1594
1588
Collections .emptyMap (),
1595
1589
initialCredits );
1596
1590
verify (clientFactory , times (1 )).client (any ());
@@ -1633,7 +1627,7 @@ void subscribeUnsubscribeInDifferentThreadsShouldNotDeadlock() {
1633
1627
NO_OP_SUBSCRIPTION_LISTENER ,
1634
1628
NO_OP_TRACKING_CLOSING_CALLBACK ,
1635
1629
(offset , message ) -> {},
1636
- null ,
1630
+ LegacyFlowControlStrategyBuilderFactory . INSTANCE . builder ( null ) ,
1637
1631
Collections .emptyMap (),
1638
1632
initialCredits );
1639
1633
0 commit comments