[
https://issues.apache.org/jira/browse/ARTEMIS-4348?focusedWorklogId=869703&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-869703
]
ASF GitHub Bot logged work on ARTEMIS-4348:
-------------------------------------------
Author: ASF GitHub Bot
Created on: 07/Jul/23 05:05
Start Date: 07/Jul/23 05:05
Worklog Time Spent: 10m
Work Description: brusdev commented on code in PR #4539:
URL: https://github.com/apache/activemq-artemis/pull/4539#discussion_r1255245184
##########
artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/ActionAbstract.java:
##########
@@ -39,6 +39,8 @@ public abstract class ActionAbstract implements Action {
@Option(name = "--verbose", description = "Print additional information.")
public boolean verbose;
+ String brokerConfiguration = "broker.xml";
Review Comment:
The name `brokerConfiguration` is already used in the method `protected
Configuration getBrokerConfiguration()`
```suggestion
String brokerConfigurationFilename = "broker.xml";
```
##########
artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/messages/Transfer.java:
##########
@@ -43,7 +43,7 @@ public class Transfer extends InputAbstract {
protected String sourceURL = DEFAULT_BROKER_URL;
@Option(name = "--source-acceptor", description = "Acceptor used to build
URL towards the broker. Default: 'artemis'.")
- protected String sourceAcceptor;
+ protected String sourceAcceptor = "artemis";
Review Comment:
The `DEFAULT_BROKER_ACCEPTOR` could be reused here:
```suggestion
protected String sourceAcceptor = DEFAULT_BROKER_ACCEPTOR;
```
##########
artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/ActionAbstract.java:
##########
@@ -113,7 +115,23 @@ public String getBrokerURLInstance(String acceptor) {
return new URI(scheme, null, host, port, null, null,
null).toString();
}
}
+
+ for (TransportConfiguration connectorConfiguration:
brokerConfiguration.getConnectorConfigurations().values()) {
+ if (connectorConfiguration.getName().equals(acceptor)) {
+ Map<String, Object> acceptorParams =
connectorConfiguration.getParams();
+ 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 (InetAddress.getByName(host).isAnyLocalAddress()) {
+ host = "localhost";
+ }
+
+ return new URI(scheme, null, host, port, null, null,
null).toString();
+ }
+ }
Review Comment:
This block of the code is causing a duplication warning in my IDE because is
very similar to the block of code for the acceptors.
##########
artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/ActionAbstract.java:
##########
@@ -113,7 +115,23 @@ public String getBrokerURLInstance(String acceptor) {
return new URI(scheme, null, host, port, null, null,
null).toString();
}
}
+
+ for (TransportConfiguration connectorConfiguration:
brokerConfiguration.getConnectorConfigurations().values()) {
+ if (connectorConfiguration.getName().equals(acceptor)) {
+ Map<String, Object> acceptorParams =
connectorConfiguration.getParams();
+ 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 (InetAddress.getByName(host).isAnyLocalAddress()) {
+ host = "localhost";
+ }
+
+ return new URI(scheme, null, host, port, null, null,
null).toString();
+ }
+ }
} catch (Exception e) {
+ e.printStackTrace();
Review Comment:
Why is not the stack trace printed using `getActionContext().out` ?
Issue Time Tracking
-------------------
Worklog Id: (was: 869703)
Time Spent: 20m (was: 10m)
> CLI Abstract Connector should parse connectors if can't find acceptor on
> broker.xml
> -----------------------------------------------------------------------------------
>
> Key: ARTEMIS-4348
> URL: https://issues.apache.org/jira/browse/ARTEMIS-4348
> Project: ActiveMQ Artemis
> Issue Type: Improvement
> Reporter: Clebert Suconic
> Assignee: Clebert Suconic
> Priority: Major
> Fix For: 2.30.0
>
> Time Spent: 20m
> Remaining Estimate: 0h
>
> In the advent a broker.xml does not have the acceptor named "artemis"
> defined, it should try parsing the connector named "artemis" for the default
> connector URI.
> This is useful in environments where the broker.xml was modified but it still
> has the default connector.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)