Reputation: 23352
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?
Upvotes: 7
Views: 15679
Reputation: 704
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.
Upvotes: 7
Reputation: 197
Did you try connecting without supplying userName & password, by default you should be able to do that.
ConnectionFactory connectionFactoryProd = new ActiveMQConnectionFactory("failover://tcp://yourServerWhereActiveMqIs:61616");
Connection connectionProd = connectionFactoryProd.createConnection();
connectionProd.start();
Upvotes: 0