This is an automated email from the ASF dual-hosted git repository.

robbie pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/activemq-artemis.git


The following commit(s) were added to refs/heads/main by this push:
     new 73d1492598 ARTEMIS-5679 Close the connection factory when the CLI perf 
command ends
73d1492598 is described below

commit 73d14925984296569488434bd7e02d364dfa28a9
Author: Domenico Francesco Bruscino <[email protected]>
AuthorDate: Tue Sep 23 17:40:31 2025 +0200

    ARTEMIS-5679 Close the connection factory when the CLI perf command ends
---
 .../cli/commands/messages/perf/PerfCommand.java    | 26 ++++++++++++----------
 1 file changed, 14 insertions(+), 12 deletions(-)

diff --git 
a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/messages/perf/PerfCommand.java
 
b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/messages/perf/PerfCommand.java
index e551b5a233..33407a3adf 100644
--- 
a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/messages/perf/PerfCommand.java
+++ 
b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/messages/perf/PerfCommand.java
@@ -29,6 +29,7 @@ import java.util.concurrent.locks.LockSupport;
 import org.apache.activemq.artemis.cli.commands.ActionContext;
 import org.apache.activemq.artemis.cli.commands.messages.ConnectionAbstract;
 import org.apache.activemq.artemis.cli.commands.messages.DestAbstract;
+import org.apache.activemq.artemis.cli.factory.ConnectionFactoryClosable;
 import picocli.CommandLine.Option;
 import picocli.CommandLine.Parameters;
 
@@ -75,20 +76,21 @@ public abstract class PerfCommand extends 
ConnectionAbstract {
          context.out.println("--tx-size is deprecated, please use 
--commit-interval");
          commitInterval = txSize;
       }
-      final ConnectionFactory factory = createConnectionFactory(brokerURL, 
user, password, null, protocol);
-      final Destination[] jmsDestinations = lookupDestinations(factory, 
destinations, numDestinations);
-      Runtime.getRuntime().addShutdownHook(new Thread(() -> {
-         onInterruptBenchmark();
-         try {
-            completed.await();
-         } catch (InterruptedException ignored) {
+      try (ConnectionFactoryClosable factory = 
createConnectionFactory(brokerURL, user, password, null, protocol)) {
+         final Destination[] jmsDestinations = lookupDestinations(factory, 
destinations, numDestinations);
+         Runtime.getRuntime().addShutdownHook(new Thread(() -> {
+            onInterruptBenchmark();
+            try {
+               completed.await();
+            } catch (InterruptedException ignored) {
 
+            }
+         }));
+         try {
+            onExecuteBenchmark(factory, jmsDestinations, context);
+         } finally {
+            completed.countDown();
          }
-      }));
-      try {
-         onExecuteBenchmark(factory, jmsDestinations, context);
-      } finally {
-         completed.countDown();
       }
       return null;
    }


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information, visit: https://activemq.apache.org/contact


Reply via email to