activemq用户无权创建:topic://ActiveMQ.Advisory.Connection

时间:2015-08-19 11:08:42

标签: authorization activemq

我正在尝试在activemq中使用授权,但现在已经停留了一段时间。

这是我的java代码,当我删除授权插件时一切正常。我正在尝试创建一个名为" room2"。

的主题
        Context jndiContext = new InitialContext();
        ConnectionFactory connectionFactory;
        connectionFactory = (ConnectionFactory) jndiContext
                .lookup("ConnectionFactory");
        connection = connectionFactory.createConnection("system", "manager");
        session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
        Topic t = session.createTopic("room2");

这是我的activemq.xml:

<plugins>
                <simpleAuthenticationPlugin>
                        <users>
                                <authenticationUser username="system" password="manager"
                                        groups="admins,publishers,consumers"/>
                                <authenticationUser username="user" password="password"
                                        groups="admins,users,publishers"/>
                                <authenticationUser username="guest" password="password" groups="guests"/>
                        </users>
                </simpleAuthenticationPlugin>
                 <authorizationPlugin>
                        <map>
                                <authorizationMap>
                                        <authorizationEntries>
                                                <authorizationEntry topic="room2" read="consumers" write="publishers" admin="admins" />
                                        </authorizationEntries>
                                </authorizationMap>
                        </map>
                </authorizationPlugin> 
        </plugins>

这是我得到的错误:

User system is not authorized to create: topic://ActiveMQ.Advisory.Connection

如果我使用<authorizationEntry topic=">" read="consumers" write="publishers" admin="admins" />,那么它运作正常,那么>究竟是什么意思?

1 个答案:

答案 0 :(得分:5)

您需要分配角色以允许创建咨询主题,除非您只是禁用它们。该网站的一个例子如下。

<authorizationEntry topic="ActiveMQ.Advisory.>" read="guests,users" write="guests,users" admin="guests,users"/>

请参阅文档here