活动的Mq:如何阻止活动的mq创建不存在的队列 [英] Active Mq : How to stop active mq from creating queue which doesnt exist

查看:169
本文介绍了活动的Mq:如何阻止活动的mq创建不存在的队列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何停止活动的mq创建不存在的队列? 我正在使用Active MQ来存储消息,但是如果Itbdoewnt存在,则Active Mq会创建一个队列.如果它不存在,我不希望它创建一个队列

How to stop active mq from creating queue which doesnt exist? I am using Active mq for storing message but active Mq creates a queue if itbdoewnt exist. I dont want it to create a queue if it doesnt exist

推荐答案

您需要通过设置authorizationPlugin来限制目标的创建:

you need to limit destinations creation by setting an authorizationPlugin :

只有具有管理员角色的用户可以发送和阅读消息以及创建目的地

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

添加到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>

添加到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;
};

添加到users.properties:

q_consumers=q_consumers_pwd
q_producers=q_producers_pwd
admin=admin

添加到groups.properties:

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

创建连接时,您必须通过用户& pwd:

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

这篇关于活动的Mq:如何阻止活动的mq创建不存在的队列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆