chennaji9 opened a new issue, #11327:
URL: https://github.com/apache/rocketmq/issues/11327

   ### Description
   
   The operations-demo producer 
`example/src/main/java/org/apache/rocketmq/example/operation/Producer.java` 
parses the required `-c` message count only inside the send loop condition, 
after the producer has already been created and started:
   
   ```java
   DefaultMQProducer producer = new DefaultMQProducer(group);
   producer.setInstanceName(Long.toString(System.currentTimeMillis()));
   
   producer.start();
   
   for (int i = 0; i < Integer.parseInt(msgCount); i++) {
   ```
   
   Consequences for argument validation:
   
   - A non-numeric `-c` value throws `NumberFormatException` **after** 
`producer.start()` — the exception escapes `main`, the `producer.shutdown()` at 
the end is never reached, and the client instance is left to be cleaned up by 
JVM exit hooks.
   - A negative `-c` value starts the producer, sends nothing, and shuts down 
"successfully" with no indication the input was invalid — the invalid count is 
silently treated as "send zero messages".
   
   Argument validation belongs before any client resource is created.
   
   ### Expected behavior
   
   Parse and validate `-c` once, before constructing/starting the producer: a 
non-numeric or negative value should print a clear message and exit without 
starting the producer; the send loop uses the parsed value.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to