如何在ActiveMQ 5.11.0中限制队列删除或清除?

时间:2016-11-16 05:40:39

标签: java activemq

我想知道如何限制用户删除Activemq中的队列。我使用simpleAuthenticationPlugin和authorizationPlugin来配置用户和访问管理。

<destinations>              
        <queue physicalName="QUEUEA" />
        <queue physicalName="QUEUEB" />
</destinations>

<plugins>
       <simpleAuthenticationPlugin anonymousAccessAllowed="false">
           <users>  
                <authenticationUser username="admin"    password="admin" groups="admins"/>
                <authenticationUser username="user1"    password="pwd1" groups="user1group"/>   
                <authenticationUser username="user2" password="pwd2" groups="user2group"/>                  
            </users>
        </simpleAuthenticationPlugin>
<authorizationPlugin>
            <map>
                <authorizationMap>
                    <authorizationEntries>                          
                            <authorizationEntry queue = "QUEUEA.>" read="user1group" write="user1group" admin="admins"/>
                            <authorizationEntry queue = "QUEUEB.>" read="user2group" write="user2group" admin="admins"/>
                            <authorizationEntry queue=">" read="admins" write="admins" admin="admins" />
                            <authorizationEntry topic="ActiveMQ.Advisory.>" read="user2group,user1group" write="user2group,user1group" admin="admins,user2group,user1group" />
                    </authorizationEntries>
                </authorizationMap>
            </map>
        </authorizationPlugin>
</plugins>

我正在寻找阻止用户删除和清除任何队列的配置。我用来删除队列的示例代码:

public static void deleteDestinationQueue(String username, String password, String destName) throws JMSException{       
    ConnectionFactory connectionFactory = new ActiveMQConnectionFactory(ActiveMQConnection.DEFAULT_BROKER_URL);
    ActiveMQConnection connection = null;
    try {
        connection = (ActiveMQConnection) connectionFactory.createConnection(username,password);
        ActiveMQDestination destination = ActiveMQDestination.createDestination(destName, ActiveMQDestination.QUEUE_TYPE);  
        connection.destroyDestination(destination);
    } catch (JMSException e) {
        e.printStackTrace();
    } finally{
        connection.close();
    }       
}

0 个答案:

没有答案