32
32
import com .rabbitmq .stream .impl .Client .ClientParameters ;
33
33
import com .rabbitmq .stream .impl .Client .Response ;
34
34
import com .rabbitmq .stream .impl .Client .StreamParametersBuilder ;
35
+ import io .netty .buffer .ByteBufAllocator ;
36
+ import io .netty .buffer .UnpooledByteBufAllocator ;
35
37
import java .io .ByteArrayOutputStream ;
36
38
import java .io .DataOutputStream ;
37
39
import java .net .UnknownHostException ;
@@ -477,9 +479,11 @@ void consume() throws Exception {
477
479
client .close ();
478
480
}
479
481
480
- @ Test
481
- void publishAndConsume () throws Exception {
482
- int publishCount = 1000000 ;
482
+ @ ParameterizedTest
483
+ @ ValueSource (booleans = {true , false })
484
+ void publishAndConsume (boolean directBuffer ) throws Exception {
485
+ ByteBufAllocator allocator = new UnpooledByteBufAllocator (directBuffer );
486
+ int publishCount = 1_000_000 ;
483
487
484
488
CountDownLatch consumedLatch = new CountDownLatch (publishCount );
485
489
Client .ChunkListener chunkListener =
@@ -494,6 +498,7 @@ void publishAndConsume() throws Exception {
494
498
Client client =
495
499
cf .get (
496
500
new Client .ClientParameters ()
501
+ .byteBufAllocator (allocator )
497
502
.chunkListener (chunkListener )
498
503
.messageListener (messageListener ));
499
504
client .subscribe (b (1 ), stream , OffsetSpecification .first (), credit );
@@ -504,6 +509,7 @@ void publishAndConsume() throws Exception {
504
509
Client publisher =
505
510
cf .get (
506
511
new Client .ClientParameters ()
512
+ .byteBufAllocator (allocator )
507
513
.publishConfirmListener (
508
514
(publisherId , correlationId ) -> confirmedLatch .countDown ()));
509
515
int messageId = 0 ;
0 commit comments