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

tabish 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 b02990fe00 ARTEMIS-5718 fix default max-hops during broker instance 
creation
b02990fe00 is described below

commit b02990fe00d4ce94d8af205ffe67e2b1b42595a4
Author: Justin Bertram <[email protected]>
AuthorDate: Thu Oct 23 16:30:41 2025 -0500

    ARTEMIS-5718 fix default max-hops during broker instance creation
---
 .../activemq/artemis/cli/commands/Create.java       |  4 +++-
 .../org/apache/activemq/cli/test/ArtemisTest.java   | 21 +++++++++++++++++++++
 2 files changed, 24 insertions(+), 1 deletion(-)

diff --git 
a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Create.java
 
b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Create.java
index 55028957f3..8cb987bb93 100644
--- 
a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Create.java
+++ 
b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Create.java
@@ -58,6 +58,8 @@ public class Create extends InstallAbstract {
 
    private static final Integer MQTT_PORT = 1883;
 
+   public static final Integer DEFAULT_MAX_HOPS = 1;
+
    /*  
**********************************************************************************
     *  Note for developers: These are tested at StreamClassPathTest on the 
unit test.
     *  This is to make sure maven or something else is not hiding these 
resources.
@@ -163,7 +165,7 @@ public class Create extends InstallAbstract {
    private boolean clustered = false;
 
    @Option(names = "--max-hops", description = "Number of hops on the cluster 
configuration.")
-   private int maxHops = 0;
+   private int maxHops = DEFAULT_MAX_HOPS;
 
    @Option(names = "--message-load-balancing", description = "Message load 
balancing policy for cluster. Default: ON_DEMAND. Valid values: ON_DEMAND, 
STRICT, OFF, OFF_WITH_REDISTRIBUTION.")
    private MessageLoadBalancingType messageLoadBalancing = 
MessageLoadBalancingType.ON_DEMAND;
diff --git 
a/artemis-cli/src/test/java/org/apache/activemq/cli/test/ArtemisTest.java 
b/artemis-cli/src/test/java/org/apache/activemq/cli/test/ArtemisTest.java
index d6e624d28b..b8c606979a 100644
--- a/artemis-cli/src/test/java/org/apache/activemq/cli/test/ArtemisTest.java
+++ b/artemis-cli/src/test/java/org/apache/activemq/cli/test/ArtemisTest.java
@@ -194,6 +194,27 @@ public class ArtemisTest extends CliTestBase {
       Artemis.main("create", instance1.getAbsolutePath(), "--silent", 
"--no-fsync", "--no-autotune");
    }
 
+   @Test
+   @Timeout(60)
+   public void testDefaultMaxHops() throws Exception {
+      testMaxHops(Create.DEFAULT_MAX_HOPS);
+   }
+
+   @Test
+   @Timeout(60)
+   public void testCustomMaxHops() throws Exception {
+      testMaxHops(Create.DEFAULT_MAX_HOPS + 1);
+   }
+
+   private void testMaxHops(int maxHops) throws Exception {
+      List<String> args = new ArrayList<>(List.of("--silent", "--no-autotune", 
"--clustered"));
+      if (maxHops != Create.DEFAULT_MAX_HOPS) {
+         args.add("--max-hops");
+         args.add(String.valueOf(maxHops));
+      }
+      FileConfiguration configuration = 
createFileConfiguration(getTestMethodName(), args.toArray(String[]::new));
+      assertEquals(maxHops, 
configuration.getClusterConfigurations().get(0).getMaxHops());
+   }
 
    @Test
    @Timeout(60)


---------------------------------------------------------------------
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