Uploaded image for project: 'ActiveMQ Artemis'
  1. ActiveMQ Artemis
  2. ARTEMIS-1473

System property BROKER_BIND_URL with parameters will not work if AMQ_USER and AMQ_PASSWORD also set

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 2.3.0
    • 2.4.0
    • None
    • None

    Description

      I try to add a connection factory resource in Tomcat like this:

      <Resource name="jms/connectionFactory" 
                  auth="Container" 
                  type="org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory" 
                  factory="org.apache.naming.factory.BeanFactory"
                  minLargeMessageSize="1048576"
                  user="xxx"
                  password="xxx" />
      

      And pass transport configuration through system property

      -DBROKER_BIND_URL=tcp://localhost:61616?compressLargeMessages=true -DAMQ_USER=xxx -DAMQ_PASSWORD=xxx
      

      The final URL will be "tcp://localhost:61616?compressLargeMessages=true?user=xxx&password=xxx", and we lost compressLargeMessages and user.

      In org.apache.activemq.artemis.jms.client.DefaultConnectionProperties.java from 2.3.0

      static {
            String host = getProperty("localhost", "AMQ_HOST", "org.apache.activemq.AMQ_HOST");
            String port = getProperty("61616", "AMQ_PORT", "org.apache.activemq.AMQ_PORT");
            DEFAULT_BROKER_HOST = host;
            DEFAULT_BROKER_PORT = Integer.parseInt(port);
            String url = getProperty("tcp://" + host + ":" + port, "org.apache.activemq.BROKER_BIND_URL", "BROKER_BIND_URL");
            DEFAULT_USER = getProperty(null, "AMQ_USER", "org.apache.activemq.AMQ_USER");
            DEFAULT_PASSWORD = getProperty(null, "AMQ_PASSWORD", "org.apache.activemq.AMQ_PASSWORD");
      
            if (DEFAULT_USER != null && DEFAULT_PASSWORD != null) {
               url += "?user=" + DEFAULT_USER + "&password=" + DEFAULT_PASSWORD;
            }
      
            DEFAULT_BROKER_BIND_URL = url;
            // TODO: improve this once we implement failover:// as ActiveMQ5 does
            DEFAULT_BROKER_URL = DEFAULT_BROKER_BIND_URL;
         }
      

      I don't think we need append user&password to url, cause ActiveMQConnectionFactory will take care of user/password, and this is the only usage of the url as far as i know.

      Attachments

        Activity

          People

            jbertram Justin Bertram
            huaishk shoukun huai
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: