title: Why username and password are not respected in activemq createConnection
body: <p>I created a one and only broker in activemq and I am using the following code to produce and consume messages. I took this code <a href="http://www.mastertheboss.com/jboss-server/jboss-jms/introduction-to-activemq-artemis" rel="nofollow noreferrer">from here</a>.</p>
  <pre><code>public boolean runExample() throws Exception {
          Connection connection = null;
          InitialContext initialContext = null;
          try {
              Properties properties = new Properties();
              properties.put(&quot;java.naming.factory.initial&quot;, &quot;org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory&quot;);
              properties.put(&quot;connectionFactory.ConnectionFactory&quot;, &quot;tcp://localhost:61616&quot;);
              properties.put(&quot;queue.queue/exampleQueue&quot;, &quot;exampleQueue&quot;);
              
              initialContext = new InitialContext(properties);
              
              Queue queue = (Queue) initialContext.lookup(&quot;queue/exampleQueue&quot;);
              
              ConnectionFactory connectionFactory = (ConnectionFactory) initialContext.lookup(&quot;ConnectionFactory&quot;);
              connection = connectionFactory.createConnection(&quot;admin&quot;, &quot;admin&quot;);//brokerone
              Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
              MessageProducer producer = session.createProducer(queue);
              TextMessage message = session.createTextMessage(&quot;This is a text message&quot;);
  
              System.out.println(&quot;Sent message: &quot; + message.getText());
              producer.send(message);
              MessageConsumer messageConsumer = session.createConsumer(queue);
              connection.start();
              TextMessage messageReceived = (TextMessage) messageConsumer.receive(5000);
              System.out.println(&quot;Received message: &quot; + messageReceived.getText());
  
              return true;
          } finally {
              if (initialContext != null) {
                  initialContext.close();
              }
              if (connection != null) {
                  connection.close();
              }
          }
      }
  </code></pre>
  <p>Now, while creating connection if I put any random string for password in <code>connectionFactory.createConnection</code> method then it still creates connection and I can see the produced messages in broker console. I looked up the <a href="http://activemq.apache.org/maven/apidocs/org/apache/activemq/ActiveMQConnectionFactory.html#createConnection-java.lang.String-java.lang.String-" rel="nofollow noreferrer">documentation</a> and <a href="https://docs.oracle.com/javaee/6/api/javax/jms/ConnectionFactory.html" rel="nofollow noreferrer">here</a> for more explanation but it also says that the strings passed in createConnection method are username and password.</p>
  <p>So now, my question is what is the purpose of username and password when they are not used while creating connection?</p>
  <p>Edit1:</p>
  <p>broker.xml (after removing bulk commented lines)</p>
  <pre><code>&lt;configuration xmlns=&quot;urn:activemq&quot;
                 xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
                 xmlns:xi=&quot;http://www.w3.org/2001/XInclude&quot;
                 xsi:schemaLocation=&quot;urn:activemq /schema/artemis-configuration.xsd&quot;&gt;
  
     &lt;core xmlns=&quot;urn:activemq:core&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
           xsi:schemaLocation=&quot;urn:activemq:core &quot;&gt;
  
        &lt;name&gt;0.0.0.0&lt;/name&gt;
        &lt;persistence-enabled&gt;true&lt;/persistence-enabled&gt;    
        &lt;journal-type&gt;NIO&lt;/journal-type&gt;
        &lt;paging-directory&gt;data/paging&lt;/paging-directory&gt;
        &lt;bindings-directory&gt;data/bindings&lt;/bindings-directory&gt;
        &lt;journal-directory&gt;data/journal&lt;/journal-directory&gt;
        &lt;large-messages-directory&gt;data/large-messages&lt;/large-messages-directory&gt;
        &lt;journal-datasync&gt;true&lt;/journal-datasync&gt;
        &lt;journal-min-files&gt;2&lt;/journal-min-files&gt;
        &lt;journal-pool-files&gt;10&lt;/journal-pool-files&gt;
        &lt;journal-device-block-size&gt;4096&lt;/journal-device-block-size&gt;
        &lt;journal-file-size&gt;10M&lt;/journal-file-size&gt;
        &lt;journal-buffer-timeout&gt;1192000&lt;/journal-buffer-timeout&gt;
        &lt;!--        When using ASYNCIO, this will determine the writing queue depth for libaio.       --&gt;
        &lt;journal-max-io&gt;1&lt;/journal-max-io&gt;     
        &lt;!-- how often we are looking for how many bytes are being used on the disk in ms --&gt;
        &lt;disk-scan-period&gt;5000&lt;/disk-scan-period&gt;
  
        &lt;!-- once the disk hits this limit the system will block, or close the connection in certain protocols that won't support flow control. --&gt;
        &lt;max-disk-usage&gt;90&lt;/max-disk-usage&gt;
  
        &lt;!-- should the broker detect dead locks and other issues --&gt;
        &lt;critical-analyzer&gt;true&lt;/critical-analyzer&gt;
        &lt;critical-analyzer-timeout&gt;120000&lt;/critical-analyzer-timeout&gt;
        &lt;critical-analyzer-check-period&gt;60000&lt;/critical-analyzer-check-period&gt;
        &lt;critical-analyzer-policy&gt;HALT&lt;/critical-analyzer-policy&gt;      
        &lt;page-sync-timeout&gt;1192000&lt;/page-sync-timeout&gt;
  
        &lt;acceptors&gt;
           &lt;!-- Acceptor for every supported protocol --&gt;
           &lt;acceptor name=&quot;artemis&quot;&gt;tcp://0.0.0.0:61616?tcpSendBufferSize=1048576;tcpReceiveBufferSize=1048576;amqpMinLargeMessageSize=102400;protocols=CORE,AMQP,STOMP,HORNETQ,MQTT,OPENWIRE;useEpoll=true;amqpCredits=1000;amqpLowCredits=300;amqpDuplicateDetection=true&lt;/acceptor&gt;
           &lt;!-- AMQP Acceptor.  Listens on default AMQP port for AMQP traffic.--&gt;
           &lt;acceptor name=&quot;amqp&quot;&gt;tcp://0.0.0.0:5672?tcpSendBufferSize=1048576;tcpReceiveBufferSize=1048576;protocols=AMQP;useEpoll=true;amqpCredits=1000;amqpLowCredits=300;amqpMinLargeMessageSize=102400;amqpDuplicateDetection=true&lt;/acceptor&gt;
           &lt;!-- STOMP Acceptor. --&gt;
           &lt;acceptor name=&quot;stomp&quot;&gt;tcp://0.0.0.0:61613?tcpSendBufferSize=1048576;tcpReceiveBufferSize=1048576;protocols=STOMP;useEpoll=true&lt;/acceptor&gt;
           &lt;!-- HornetQ Compatibility Acceptor.  Enables HornetQ Core and STOMP for legacy HornetQ clients. --&gt;
           &lt;acceptor name=&quot;hornetq&quot;&gt;tcp://0.0.0.0:5445?anycastPrefix=jms.queue.;multicastPrefix=jms.topic.;protocols=HORNETQ,STOMP;useEpoll=true&lt;/acceptor&gt;
           &lt;!-- MQTT Acceptor --&gt;
           &lt;acceptor name=&quot;mqtt&quot;&gt;tcp://0.0.0.0:1883?tcpSendBufferSize=1048576;tcpReceiveBufferSize=1048576;protocols=MQTT;useEpoll=true&lt;/acceptor&gt;
        &lt;/acceptors&gt;
        
        &lt;security-settings&gt;
           &lt;security-setting match=&quot;#&quot;&gt;
              &lt;permission type=&quot;createNonDurableQueue&quot; roles=&quot;amq&quot;/&gt;
              &lt;permission type=&quot;deleteNonDurableQueue&quot; roles=&quot;amq&quot;/&gt;
              &lt;permission type=&quot;createDurableQueue&quot; roles=&quot;amq&quot;/&gt;
              &lt;permission type=&quot;deleteDurableQueue&quot; roles=&quot;amq&quot;/&gt;
              &lt;permission type=&quot;createAddress&quot; roles=&quot;amq&quot;/&gt;
              &lt;permission type=&quot;deleteAddress&quot; roles=&quot;amq&quot;/&gt;
              &lt;permission type=&quot;consume&quot; roles=&quot;amq&quot;/&gt;
              &lt;permission type=&quot;browse&quot; roles=&quot;amq&quot;/&gt;
              &lt;permission type=&quot;send&quot; roles=&quot;amq&quot;/&gt;
              &lt;!-- we need this otherwise ./artemis data imp wouldn't work --&gt;
              &lt;permission type=&quot;manage&quot; roles=&quot;amq&quot;/&gt;
           &lt;/security-setting&gt;
        &lt;/security-settings&gt;
  
        &lt;address-settings&gt;
           &lt;!-- if you define auto-create on certain queues, management has to be auto-create --&gt;
           &lt;address-setting match=&quot;activemq.management#&quot;&gt;
              &lt;dead-letter-address&gt;DLQ&lt;/dead-letter-address&gt;
              &lt;expiry-address&gt;ExpiryQueue&lt;/expiry-address&gt;
              &lt;redelivery-delay&gt;0&lt;/redelivery-delay&gt;
              &lt;!-- with -1 only the global-max-size is in use for limiting --&gt;
              &lt;max-size-bytes&gt;-1&lt;/max-size-bytes&gt;
              &lt;message-counter-history-day-limit&gt;10&lt;/message-counter-history-day-limit&gt;
              &lt;address-full-policy&gt;PAGE&lt;/address-full-policy&gt;
              &lt;auto-create-queues&gt;true&lt;/auto-create-queues&gt;
              &lt;auto-create-addresses&gt;true&lt;/auto-create-addresses&gt;
              &lt;auto-create-jms-queues&gt;true&lt;/auto-create-jms-queues&gt;
              &lt;auto-create-jms-topics&gt;true&lt;/auto-create-jms-topics&gt;
           &lt;/address-setting&gt;
           &lt;!--default for catch all--&gt;
           &lt;address-setting match=&quot;#&quot;&gt;
              &lt;dead-letter-address&gt;DLQ&lt;/dead-letter-address&gt;
              &lt;expiry-address&gt;ExpiryQueue&lt;/expiry-address&gt;
              &lt;redelivery-delay&gt;0&lt;/redelivery-delay&gt;
              &lt;!-- with -1 only the global-max-size is in use for limiting --&gt;
              &lt;max-size-bytes&gt;-1&lt;/max-size-bytes&gt;
              &lt;message-counter-history-day-limit&gt;10&lt;/message-counter-history-day-limit&gt;
              &lt;address-full-policy&gt;PAGE&lt;/address-full-policy&gt;
              &lt;auto-create-queues&gt;true&lt;/auto-create-queues&gt;
              &lt;auto-create-addresses&gt;true&lt;/auto-create-addresses&gt;
              &lt;auto-create-jms-queues&gt;true&lt;/auto-create-jms-queues&gt;
              &lt;auto-create-jms-topics&gt;true&lt;/auto-create-jms-topics&gt;
           &lt;/address-setting&gt;
        &lt;/address-settings&gt;
  
        &lt;addresses&gt;
           &lt;address name=&quot;DLQ&quot;&gt;
              &lt;anycast&gt;
                 &lt;queue name=&quot;DLQ&quot; /&gt;
              &lt;/anycast&gt;
           &lt;/address&gt;
           &lt;address name=&quot;ExpiryQueue&quot;&gt;
              &lt;anycast&gt;
                 &lt;queue name=&quot;ExpiryQueue&quot; /&gt;
              &lt;/anycast&gt;
           &lt;/address&gt;
  
        &lt;/addresses&gt;
     &lt;/core&gt;
  &lt;/configuration&gt;
  </code></pre>
  <p>bootstrap.xml</p>
  <pre><code>&lt;broker xmlns=&quot;http://activemq.org/schema&quot;&gt;
  
     &lt;jaas-security domain=&quot;activemq&quot;/&gt;
  
     &lt;!-- artemis.URI.instance is parsed from artemis.instance by the CLI startup.
          This is to avoid situations where you could have spaces or special characters on this URI --&gt;
     &lt;server configuration=&quot;file:/C:/dev/artemis/apache-artemis-2.13.0/bin/brokerone/etc//broker.xml&quot;/&gt;
  
     &lt;!-- The web server is only bound to localhost by default --&gt;
     &lt;web bind=&quot;http://localhost:8161&quot; path=&quot;web&quot;&gt;
         &lt;app url=&quot;activemq-branding&quot; war=&quot;activemq-branding.war&quot;/&gt;
         &lt;app url=&quot;artemis-plugin&quot; war=&quot;artemis-plugin.war&quot;/&gt;
         &lt;app url=&quot;console&quot; war=&quot;console.war&quot;/&gt;
     &lt;/web&gt;
  
  
  &lt;/broker&gt;
  </code></pre>
  <p>login.config</p>
  <pre><code>activemq {
     org.apache.activemq.artemis.spi.core.security.jaas.PropertiesLoginModule sufficient
         debug=false
         reload=true
         org.apache.activemq.jaas.properties.user=&quot;artemis-users.properties&quot;
         org.apache.activemq.jaas.properties.role=&quot;artemis-roles.properties&quot;;
  
     org.apache.activemq.artemis.spi.core.security.jaas.GuestLoginModule sufficient
         debug=false
         org.apache.activemq.jaas.guest.user=&quot;admin&quot;
         org.apache.activemq.jaas.guest.role=&quot;amq&quot;;
  };
  </code></pre>