3030import com .rabbitmq .stream .EnvironmentBuilder .TlsConfiguration ;
3131import com .rabbitmq .stream .OffsetSpecification ;
3232import com .rabbitmq .stream .Producer ;
33+ import com .rabbitmq .stream .ProducerBuilder ;
3334import com .rabbitmq .stream .StreamCreator ;
3435import com .rabbitmq .stream .StreamCreator .LeaderLocator ;
3536import com .rabbitmq .stream .StreamException ;
@@ -258,6 +259,16 @@ public class StreamPerfTest implements Callable<Integer> {
258259 converter = Utils .OneTo255RangeIntegerTypeConverter .class )
259260 private int producersByConnection ;
260261
262+ @ CommandLine .Option (
263+ names = {"--producer-names" , "-pn" },
264+ description =
265+ "naming strategy for producer names. Valid values are 'uuid' or a pattern with "
266+ + "stream name and producer index as arguments. "
267+ + "If set, a publishing ID is automatically assigned to each outbound message." ,
268+ defaultValue = "" ,
269+ converter = Utils .NameStrategyConverter .class )
270+ private BiFunction <String , Integer , String > producerNameStrategy ;
271+
261272 @ CommandLine .Option (
262273 names = {"--tracking-consumers-by-connection" , "-ccbc" },
263274 description = "number of tracking consumers by connection. Value must be between 1 and 255." ,
@@ -284,7 +295,7 @@ public class StreamPerfTest implements Callable<Integer> {
284295 "naming strategy for consumer names. Valid values are 'uuid' or a pattern with "
285296 + "stream name and consumer index as arguments." ,
286297 defaultValue = "%s-%d" ,
287- converter = Utils .ConsumerNameStrategyConverter .class )
298+ converter = Utils .NameStrategyConverter .class )
288299 private BiFunction <String , Integer , String > consumerNameStrategy ;
289300
290301 @ CommandLine .Option (
@@ -597,10 +608,17 @@ public Integer call() throws Exception {
597608 }
598609
599610 String stream = stream ();
611+ ProducerBuilder producerBuilder = environment .producerBuilder ();
612+
613+ String producerName = this .producerNameStrategy .apply (stream , i + 1 );
614+ if (producerName != "" ) {
615+ producerBuilder = producerBuilder
616+ .name (producerName )
617+ .confirmTimeout (Duration .ZERO );
618+ }
600619
601620 Producer producer =
602- environment
603- .producerBuilder ()
621+ producerBuilder
604622 .subEntrySize (this .subEntrySize )
605623 .batchSize (this .batchSize )
606624 .compression (
0 commit comments