Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use username and password for ActiveMQ JMS Connection

Tags:

java

jms

activemq

Apache ActiveMQ creates a secure connection using username and password.

InitialContext initCtx = new InitialContext();
javax.jms.ConnectionFactory qcf = (javax.jms.ConnectionFactory) initCtx.lookup(factoryName);
Connection connection = qcf.createConnection(userName, password);

Where can I found these credentials. Are these username and password configured in any ActiveMQ configuration file?

like image 612
Muhammad Imran Tariq Avatar asked Feb 11 '15 09:02

Muhammad Imran Tariq


People also ask

What is the username and password for ActiveMQ?

The default administration user name and password for the Apache ActiveMQ Administration Console is admin and admin respectively.

How do I change my ActiveMQ username and password?

String username = "admin"; String password = "anything"; ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("tcp://localhost:61616"); factory. setUserName(username); factory. setPassword(password); factory.


1 Answers

To answer your question: Indeed they are, and the name of the file where the credentials are defined is activemq.xml. It can be found in the conf directory of your ActiveMQ Installation, e.g. C:\Program Files (x86)\apache-activemq-5.10.0\conf.

Now, on this site there are rather detailed instructions on how to configure ActiveMQ to use simple authentication or JAAS, but I'll give you a quick rundown and some tips:

  • All the following stuff has to be inserted in the plugins section of aforementioned XML file.

  • Use SimpleAuthentication in order to just "add" users to groups, e.g.

        <simpleAuthenticationPlugin anonymousAccessAllowed="true">
            <users>
                <authenticationUser username="system" password="system" groups="users,admins"/>
                <authenticationUser username="admin" password="admin" groups="users,admins"/>
                <authenticationUser username="user" password="user" groups="users"/>
                <authenticationUser username="guest" password="guest" groups="guests"/>
            </users>
        </simpleAuthenticationPlugin>
    
  • Use AuthorizationPlugin to configure which groups have access to which queues and topics.

  • If you plan on using SimpleAuthentication make sure you do not have <jaasAuthenticationPlugin configuration="activemq-domain" /> in your active plugins. Just in case you plan on copying that one sample from the page I previously mentioned.

  • You might want to enable anonymous access. To do so, add the corresponding attribute to your SimpleAuthenticatoinPlugin node. Once that is done you may connect to queues without providing username and password when creating a connection.

like image 119
hschne Avatar answered Oct 06 '22 00:10

hschne