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?
The default administration user name and password for the Apache ActiveMQ Administration Console is admin and admin respectively.
String username = "admin"; String password = "anything"; ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("tcp://localhost:61616"); factory. setUserName(username); factory. setPassword(password); factory.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With