mirror of
https://github.com/apache/rocketmq.git
synced 2026-11-03 12:51:55 +08:00
ROCKETMQ-18 Clean code closes apache/incubator-rocketmq#21
This commit is contained in:
@@ -49,7 +49,7 @@ public class Producer {
|
||||
final String topic = commandLine.hasOption('t') ? commandLine.getOptionValue('t').trim() : "BenchmarkTest";
|
||||
final int threadCount = commandLine.hasOption('w') ? Integer.parseInt(commandLine.getOptionValue('w')) : 64;
|
||||
final int messageSize = commandLine.hasOption('s') ? Integer.parseInt(commandLine.getOptionValue('s')) : 128;
|
||||
final boolean keyEnable = commandLine.hasOption('k') ? Boolean.parseBoolean(commandLine.getOptionValue('k')) : false;
|
||||
final boolean keyEnable = commandLine.hasOption('k') && Boolean.parseBoolean(commandLine.getOptionValue('k'));
|
||||
|
||||
System.out.printf("topic %s threadCount %d messageSize %d keyEnable %s%n", topic, threadCount, messageSize, keyEnable);
|
||||
|
||||
@@ -140,7 +140,7 @@ public class Producer {
|
||||
|
||||
try {
|
||||
Thread.sleep(3000);
|
||||
} catch (InterruptedException e1) {
|
||||
} catch (InterruptedException ignored) {
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
statsBenchmark.getSendRequestFailedCount().incrementAndGet();
|
||||
@@ -156,7 +156,7 @@ public class Producer {
|
||||
log.error("[BENCHMARK_PRODUCER] Send Exception", e);
|
||||
try {
|
||||
Thread.sleep(3000);
|
||||
} catch (InterruptedException e1) {
|
||||
} catch (InterruptedException ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -43,8 +43,8 @@ public class TransactionProducer {
|
||||
public static void main(String[] args) throws MQClientException, UnsupportedEncodingException {
|
||||
threadCount = args.length >= 1 ? Integer.parseInt(args[0]) : 32;
|
||||
messageSize = args.length >= 2 ? Integer.parseInt(args[1]) : 1024 * 2;
|
||||
ischeck = args.length >= 3 ? Boolean.parseBoolean(args[2]) : false;
|
||||
ischeckffalse = args.length >= 4 ? Boolean.parseBoolean(args[3]) : false;
|
||||
ischeck = args.length >= 3 && Boolean.parseBoolean(args[2]);
|
||||
ischeckffalse = args.length >= 4 && Boolean.parseBoolean(args[3]);
|
||||
|
||||
final Message msg = buildMessage(messageSize);
|
||||
|
||||
|
||||
@@ -54,13 +54,7 @@ public class Producer {
|
||||
}
|
||||
|
||||
producer.shutdown();
|
||||
} catch (MQClientException e) {
|
||||
e.printStackTrace();
|
||||
} catch (RemotingException e) {
|
||||
e.printStackTrace();
|
||||
} catch (MQBrokerException e) {
|
||||
e.printStackTrace();
|
||||
} catch (InterruptedException e) {
|
||||
} catch (MQClientException | RemotingException | MQBrokerException | InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
+1
-3
@@ -45,9 +45,7 @@ public class TransactionProducer {
|
||||
System.out.printf("%s%n", sendResult);
|
||||
|
||||
Thread.sleep(10);
|
||||
} catch (MQClientException e) {
|
||||
e.printStackTrace();
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
} catch (MQClientException | UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user