2828import java .util .BitSet ;
2929import java .util .Collection ;
3030import java .util .HashSet ;
31+ import java .util .Iterator ;
3132import java .util .List ;
3233import java .util .Map ;
3334import java .util .Properties ;
@@ -453,6 +454,7 @@ public void testManualCommitSyncExisting() throws Exception {
453454 latch .countDown ();
454455 });
455456 containerProps .setAckMode (ContainerProperties .AckMode .MANUAL_IMMEDIATE );
457+ containerProps .setClientId ("myClientId" );
456458
457459 ConcurrentMessageListenerContainer <Integer , String > container =
458460 new ConcurrentMessageListenerContainer <>(cf , containerProps );
@@ -467,6 +469,9 @@ public void testManualCommitSyncExisting() throws Exception {
467469 template .flush ();
468470 assertThat (latch .await (60 , TimeUnit .SECONDS )).isTrue ();
469471 assertThat (bitSet .cardinality ()).isEqualTo (8 );
472+ Set <String > clientIds = container .getAssignmentsByClientId ().keySet ();
473+ assertThat (clientIds ).hasSize (1 );
474+ assertThat (clientIds .iterator ().next ()).isEqualTo ("myClientId-0" );
470475 container .stop ();
471476 this .logger .info ("Stop MANUAL_IMMEDIATE with Existing" );
472477 }
@@ -483,10 +488,11 @@ public void testPausedStart() throws Exception {
483488 ConcurrentMessageListenerContainerTests .this .logger .info ("paused start: " + message );
484489 latch .countDown ();
485490 });
486-
491+ containerProps . setClientId ( "myClientId" );
487492 ConcurrentMessageListenerContainer <Integer , String > container =
488493 new ConcurrentMessageListenerContainer <>(cf , containerProps );
489494 container .setConcurrency (2 );
495+ container .setAlwaysClientIdSuffix (false );
490496 container .setBeanName ("testBatch" );
491497 container .pause ();
492498 container .start ();
@@ -505,6 +511,11 @@ public void testPausedStart() throws Exception {
505511 container .resume ();
506512
507513 assertThat (latch .await (60 , TimeUnit .SECONDS )).isTrue ();
514+ Set <String > clientIds = container .getAssignmentsByClientId ().keySet ();
515+ assertThat (clientIds ).hasSize (2 );
516+ Iterator <String > iterator = clientIds .iterator ();
517+ assertThat (iterator .next ()).startsWith ("myClientId-" );
518+ assertThat (iterator .next ()).startsWith ("myClientId-" );
508519 container .stop ();
509520 this .logger .info ("Stop paused start" );
510521 }
@@ -704,9 +715,11 @@ private void testAckOnErrorWithManualImmediateGuts(String topic, boolean ackOnEr
704715 }
705716
706717 });
718+ containerProps .setClientId ("myClientId" );
707719 ConcurrentMessageListenerContainer <Integer , String > container = new ConcurrentMessageListenerContainer <>(cf ,
708720 containerProps );
709721 container .setConcurrency (1 );
722+ container .setAlwaysClientIdSuffix (false );
710723 container .setBeanName ("testAckOnErrorWithManualImmediate" );
711724 container .start ();
712725 ContainerTestUtils .waitForAssignment (container , embeddedKafka .getPartitionsPerTopic ());
@@ -719,6 +732,9 @@ private void testAckOnErrorWithManualImmediateGuts(String topic, boolean ackOnEr
719732 template .sendDefault (0 , 1 , "bar" );
720733 template .flush ();
721734 assertThat (latch .await (60 , TimeUnit .SECONDS )).isTrue ();
735+ Set <String > clientIds = container .getAssignmentsByClientId ().keySet ();
736+ assertThat (clientIds ).hasSize (1 );
737+ assertThat (clientIds .iterator ().next ()).isEqualTo ("myClientId" );
722738 container .stop ();
723739
724740 Consumer <Integer , String > consumer = cf .createConsumer ();
0 commit comments