@@ -189,8 +189,9 @@ public long applyAsLong(Object value) {
189
189
private final Duration rpcTimeout ;
190
190
private final List <String > saslMechanisms ;
191
191
private volatile ShutdownReason shutdownReason = null ;
192
- private final Runnable exchangeCommandVersionsCheck ;
192
+ private final Runnable streamStatsCommandVersionsCheck ;
193
193
private final boolean filteringSupported ;
194
+ private final Runnable superStreamManagementCommandVersionsCheck ;
194
195
195
196
public Client () {
196
197
this (new ClientParameters ());
@@ -376,25 +377,36 @@ public void initChannel(SocketChannel ch) {
376
377
tuneState .getHeartbeat ());
377
378
this .connectionProperties = open (parameters .virtualHost );
378
379
Set <FrameHandlerInfo > supportedCommands = maybeExchangeCommandVersions ();
379
- AtomicReference < Runnable > exchangeCommandVersionsCheckReference = new AtomicReference <>( );
380
+ AtomicBoolean streamStatsSupported = new AtomicBoolean ( false );
380
381
AtomicBoolean filteringSupportedReference = new AtomicBoolean (false );
382
+ AtomicBoolean superStreamManagementSupported = new AtomicBoolean (false );
381
383
supportedCommands .forEach (
382
384
c -> {
383
385
if (c .getKey () == COMMAND_STREAM_STATS ) {
384
- exchangeCommandVersionsCheckReference .set (() -> {} );
386
+ streamStatsSupported .set (true );
385
387
}
386
388
if (c .getKey () == COMMAND_PUBLISH && c .getMaxVersion () >= VERSION_2 ) {
387
389
filteringSupportedReference .set (true );
388
390
}
391
+ if (c .getKey () == COMMAND_CREATE_SUPER_STREAM ) {
392
+ superStreamManagementSupported .set (true );
393
+ }
389
394
});
390
- this .exchangeCommandVersionsCheck =
391
- exchangeCommandVersionsCheckReference .get () == null
392
- ? () -> {
395
+ this .streamStatsCommandVersionsCheck =
396
+ streamStatsSupported .get ()
397
+ ? () -> {}
398
+ : () -> {
393
399
throw new UnsupportedOperationException (
394
400
"QueryStreamInfo is available only on RabbitMQ 3.11 or more." );
395
- }
396
- : exchangeCommandVersionsCheckReference .get ();
401
+ };
397
402
this .filteringSupported = filteringSupportedReference .get ();
403
+ this .superStreamManagementCommandVersionsCheck =
404
+ superStreamManagementSupported .get ()
405
+ ? () -> {}
406
+ : () -> {
407
+ throw new UnsupportedOperationException (
408
+ "Super stream management is available only on RabbitMQ 3.13 or more." );
409
+ };
398
410
started .set (true );
399
411
this .metricsCollector .openConnection ();
400
412
} catch (RuntimeException e ) {
@@ -678,6 +690,7 @@ Response createSuperStream(
678
690
List <String > partitions ,
679
691
List <String > routingKeys ,
680
692
Map <String , String > arguments ) {
693
+ this .superStreamManagementCommandVersionsCheck .run ();
681
694
if (partitions .isEmpty () || routingKeys .isEmpty ()) {
682
695
throw new IllegalArgumentException (
683
696
"Partitions and routing keys of a super stream cannot be empty" );
@@ -724,6 +737,7 @@ Response createSuperStream(
724
737
}
725
738
726
739
Response deleteSuperStream (String superStream ) {
740
+ this .superStreamManagementCommandVersionsCheck .run ();
727
741
int length = 2 + 2 + 4 + 2 + superStream .length ();
728
742
int correlationId = correlationSequence .incrementAndGet ();
729
743
try {
@@ -1594,7 +1608,7 @@ List<FrameHandlerInfo> exchangeCommandVersions() {
1594
1608
}
1595
1609
1596
1610
StreamStatsResponse streamStats (String stream ) {
1597
- this .exchangeCommandVersionsCheck .run ();
1611
+ this .streamStatsCommandVersionsCheck .run ();
1598
1612
if (stream == null ) {
1599
1613
throw new IllegalArgumentException ("stream must not be null" );
1600
1614
}
0 commit comments