Mr.X
Mr.X

Reputation: 41

How to stop ActiveMQ from creating a queue which doesn't exist

How to stop ActiveMQ from creating queue which doesn't exist? I am using ActiveMQ for storing message, but ActiveMQ creates a queue if it doesn't exist. I don't want it to create a queue if it doesn't exist.

Upvotes: 1

Views: 1281

Answers (1)

Hassen Bennour
Hassen Bennour

Reputation: 3913

You need to limit destinations creation by configuring the authorizationPlugin so that:

  • only users with admins role can send and read messages and create destinations
  • only users with producers role can send messages
  • only users with consumers role can read messages

add to activemq.xml:

<plugins>
    <jaasAuthenticationPlugin configuration="activemq"/>

   <authorizationPlugin>
       <map>
         <authorizationMap>
           <authorizationEntries>            
             <authorizationEntry queue="test" read="consumers" write="producers" admin="admins" />
             <authorizationEntry topic="ActiveMQ.Advisory.>" read="all" write="all" admin="all"/>
             <authorizationEntry queue="ActiveMQ.>.>" read="admins" write="admins" admin="admins"/>
           </authorizationEntries>
           <tempDestinationAuthorizationEntry>
             <tempDestinationAuthorizationEntry read="admins" write="admins" admin="admins"/>
           </tempDestinationAuthorizationEntry>
        </authorizationMap>
      </map>
   </authorizationPlugin>
</plugins>

add to login.config:

activemq {
    org.apache.activemq.jaas.PropertiesLoginModule required
        org.apache.activemq.jaas.properties.user="users.properties"
        org.apache.activemq.jaas.properties.group="groups.properties"
        reload=true;
};

add to users.properties:

q_consumers=q_consumers_pwd
q_producers=q_producers_pwd
admin=admin

add to groups.properties:

admins=admin
consumers=q_consumers
producers=q_producers
all=q_consumers,q_producers,admin

When you create a JMS Connection you have to pass user & password:

javax.jms.ConnectionFactory.createConnection(String userName, String password);

Upvotes: 2

Related Questions