4141import org .apache .rocketmq .srvutil .ServerUtil ;
4242
4343public class Producer {
44+
4445 public static void main (String [] args ) throws MQClientException , UnsupportedEncodingException {
4546
4647 Options options = ServerUtil .buildCommandlineOptions (new Options ());
@@ -54,11 +55,12 @@ public static void main(String[] args) throws MQClientException, UnsupportedEnco
5455 final int messageSize = commandLine .hasOption ('s' ) ? Integer .parseInt (commandLine .getOptionValue ('s' )) : 128 ;
5556 final boolean keyEnable = commandLine .hasOption ('k' ) && Boolean .parseBoolean (commandLine .getOptionValue ('k' ));
5657 final int propertySize = commandLine .hasOption ('p' ) ? Integer .parseInt (commandLine .getOptionValue ('p' )) : 0 ;
58+ final int tagCount = commandLine .hasOption ('l' ) ? Integer .parseInt (commandLine .getOptionValue ('l' )) : 0 ;
5759 final boolean msgTraceEnable = commandLine .hasOption ('m' ) && Boolean .parseBoolean (commandLine .getOptionValue ('m' ));
5860 final boolean aclEnable = commandLine .hasOption ('a' ) && Boolean .parseBoolean (commandLine .getOptionValue ('a' ));
5961
60- System .out .printf ("topic %s threadCount %d messageSize %d keyEnable %s traceEnable %s aclEnable %s%n" ,
61- topic , threadCount , messageSize , keyEnable , msgTraceEnable , aclEnable );
62+ System .out .printf ("topic: %s threadCount: %d messageSize: %d keyEnable: %s propertySize: %d tagCount: %d traceEnable: %s aclEnable: %s%n" ,
63+ topic , threadCount , messageSize , keyEnable , propertySize , tagCount , msgTraceEnable , aclEnable );
6264
6365 final InternalLogger log = ClientLogger .getLog ();
6466
@@ -134,6 +136,10 @@ public void run() {
134136 if (keyEnable ) {
135137 msg .setKeys (String .valueOf (beginTimestamp / 1000 ));
136138 }
139+ if (tagCount > 0 ) {
140+ long sendSucCount = statsBenchmark .getReceiveResponseSuccessCount ().get ();
141+ msg .setTags (String .format ("tag%d" , sendSucCount % tagCount ));
142+ }
137143 if (propertySize > 0 ) {
138144 if (msg .getProperties () != null ) {
139145 msg .getProperties ().clear ();
@@ -215,6 +221,10 @@ public static Options buildCommandlineOptions(final Options options) {
215221 opt .setRequired (false );
216222 options .addOption (opt );
217223
224+ opt = new Option ("l" , "tagCount" , true , "Tag count, Default: 0" );
225+ opt .setRequired (false );
226+ options .addOption (opt );
227+
218228 opt = new Option ("m" , "msgTraceEnable" , true , "Message Trace Enable, Default: false" );
219229 opt .setRequired (false );
220230 options .addOption (opt );
0 commit comments