@@ -47,21 +47,6 @@ public static ArrayList<RecordId> doProduceAndGatherRid(
4747 return rids ;
4848 }
4949
50- public static ArrayList <RecordId > doProduceWithKey (
51- Producer producer , int payloadSize , int recordsNums , String key ) {
52- var rids = new ArrayList <RecordId >();
53- Random rand = new Random ();
54- byte [] rRec = new byte [payloadSize ];
55- var writes = new ArrayList <CompletableFuture <RecordId >>();
56- for (int i = 0 ; i < recordsNums ; i ++) {
57- rand .nextBytes (rRec );
58- Record record = Record .newBuilder ().rawRecord (rRec ).key (key ).build ();
59- writes .add (producer .write (record ));
60- }
61- writes .forEach (w -> rids .add (w .join ()));
62- return rids ;
63- }
64-
6550 // @Test
6651 // public void testReceiverException() throws Exception {
6752 // Consumer consumer =
@@ -547,41 +532,4 @@ public void testWriteBatchRawRecordBasedBytesSize() throws Exception {
547532 latch .await ();
548533 consumer .stopAsync ().awaitTerminated ();
549534 }
550-
551- @ Test
552- @ Order (8 )
553- public void testOrderingKeyBatch () throws Exception {
554- BufferedProducer producer =
555- client .newBufferedProducer ().stream (testStreamName )
556- .recordCountLimit (100 )
557- .flushIntervalMs (100 )
558- .build ();
559- final int count = 10 ;
560- doProduceWithKey (producer , 100 , count / 2 , "K1" );
561- doProduceWithKey (producer , 100 , count / 2 , "K2" );
562-
563- logger .info ("producer finish" );
564- producer .close ();
565-
566- CountDownLatch latch = new CountDownLatch (1 );
567- AtomicInteger index = new AtomicInteger ();
568- Consumer consumer =
569- client
570- .newConsumer ()
571- .subscription (testSubscriptionId )
572- .rawRecordReceiver (
573- (receivedRawRecord , responder ) -> {
574- responder .ack ();
575- index .incrementAndGet ();
576- logger .info ("ack for {}, idx:{}" , receivedRawRecord .getRecordId (), index .get ());
577- if (index .get () == count ) {
578- latch .countDown ();
579- }
580- })
581- .build ();
582- consumer .startAsync ().awaitRunning ();
583-
584- latch .await ();
585- consumer .stopAsync ().awaitTerminated ();
586- }
587535}
0 commit comments