You are viewing a plain text version of this content. The canonical link for it is here.
Posted to gitbox@activemq.apache.org by GitBox <gi...@apache.org> on 2020/04/19 07:30:58 UTC
[GitHub] [activemq-artemis] brusdev commented on a change in pull request
#3092: ARTEMIS-2723 Read the default CLI connector from the related broker
brusdev commented on a change in pull request #3092: ARTEMIS-2723 Read the default CLI connector from the related broker
URL: https://github.com/apache/activemq-artemis/pull/3092#discussion_r410840362
##########
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:
I pushed a new commit to simply.
----------------------------------------------------------------
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:
users@infra.apache.org
With regards,
Apache Git Services