[ 
https://issues.apache.org/jira/browse/ARTEMIS-2723?focusedWorklogId=424922&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-424922
 ]

ASF GitHub Bot logged work on ARTEMIS-2723:
-------------------------------------------

                Author: ASF GitHub Bot
            Created on: 18/Apr/20 16:50
            Start Date: 18/Apr/20 16:50
    Worklog Time Spent: 10m 
      Work Description: clebertsuconic commented on pull request #3092: 
ARTEMIS-2723 Read the default CLI connector from the related broker
URL: https://github.com/apache/activemq-artemis/pull/3092#discussion_r410721672
 
 

 ##########
 File path: 
artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/messages/ConnectionAbstract.java
 ##########
 @@ -79,6 +95,67 @@ public void setProtocol(String protocol) {
       this.protocol = protocol;
    }
 
+   @Override
+   public Object execute(ActionContext context) throws Exception {
+      super.execute(context);
+
+      if (brokerURL == null) {
+         String brokerURLInstance = getBrokerURLInstance();
+
+         if (brokerURLInstance != null) {
+            brokerURL = brokerURLInstance;
+         } else {
+            brokerURL = DEFAULT_BROKER_URL;
+         }
+      }
+
+      System.out.println("Connection brokerURL = " + brokerURL);
+
+      return null;
+   }
+
+   private String getBrokerURLInstance() {
+      if (getBrokerInstance() != null) {
+         try {
+            File xmlFile = new File(new File(getBrokerEtc()), "bootstrap.xml");
+            String configuration = xmlFile.toURI().toString().replace("file:", 
"xml:").replace("\\", "/");
+            BrokerDTO brokerDTO = 
BrokerFactory.createBrokerConfiguration(configuration, getBrokerHome(), 
getBrokerInstance(), getBrokerURIInstance());
+
+            FileConfiguration fileConfiguration = new FileConfiguration();
+            String serverConfiguration = 
brokerDTO.server.getConfigurationURI().toASCIIString();
+            FileDeploymentManager fileDeploymentManager = new 
FileDeploymentManager(serverConfiguration);
+            fileDeploymentManager.addDeployable(fileConfiguration);
+            fileDeploymentManager.readConfiguration();
+
+            for (TransportConfiguration acceptorConfiguration: 
fileConfiguration.getAcceptorConfigurations()) {
+               Map<String, Object> acceptorParams = 
acceptorConfiguration.getParams();
+               String protocols = 
ConfigurationHelper.getStringProperty(TransportConstants.PROTOCOLS_PROP_NAME, 
null, acceptorParams).toUpperCase();
+
+               if (protocols == null || 
protocols.contains(protocol.toUpperCase())) {
+                  String scheme = 
ConfigurationHelper.getStringProperty(TransportConstants.SCHEME_PROP_NAME, 
SchemaConstants.TCP, acceptorParams);
+                  String host = 
ConfigurationHelper.getStringProperty(TransportConstants.HOST_PROP_NAME, 
"localhost", acceptorParams);
+                  int port = 
ConfigurationHelper.getIntProperty(TransportConstants.PORT_PROP_NAME, 61616, 
acceptorParams);
+
+                  if (scheme.equals(SchemaConstants.VM)) {
 
 Review comment:
   if anything failed.. like you can't find the broker.xml on the ETC.. just 
use the default option.
   
   That will be true for the cases where you use the CLI from the main 
distribution. as a matter of fact you should test the options outside of the 
broker instance.
 
----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


Issue Time Tracking
-------------------

    Worklog Id:     (was: 424922)
    Time Spent: 1h  (was: 50m)

> Read the default CLI connector from the related broker
> ------------------------------------------------------
>
>                 Key: ARTEMIS-2723
>                 URL: https://issues.apache.org/jira/browse/ARTEMIS-2723
>             Project: ActiveMQ Artemis
>          Issue Type: Improvement
>            Reporter: Domenico Bruscino
>            Priority: Major
>          Time Spent: 1h
>  Remaining Estimate: 0h
>
> Artemis CLI accesses to the port of the broker through core protocol for many
> commands. However, when several brokers are installed on a single machine, 
> all the installed `artemis` command for each broker operate only one broker 
> that have `tcp://localhost:61616` by default.
> This behavior is difficult to understand and could lead to incorrect 
> operations for the different broker. The default connector could be read from 
> the broker where you are related.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to