使用AMQP 0-9-1和WSO2 MB时,权限被拒绝

时间:2013-03-31 16:41:59

标签: wso2 amqp

当尝试使用AMQP 0-9-1与WSO2 MB通信时,我收到来自WSO2 MB的Andes核心的“权限被拒绝”AMQSecurityException。发生这种情况是因为我尝试使用路由键将队列绑定到主题。任何人都可以提供有关如何将AMQP 0-9-1库与WSO2 MB一起使用的指导吗?

具体来说,我的代码尝试使用路由密钥'rkey'发布到交换'texch',并通过运行时创建的队列使用路由密钥'rkey'绑定到'texch'来消息。

WSO2 MB的输出是:

[2013-04-02 14:27:34,012]  INFO {org.wso2.andes.server.protocol.AMQProtocolEngine} -  Closing channel due to: org.wso2.andes.AMQSecurityException: Permission denied: binding rkey [error code 403: access refused]
[2013-04-02 14:27:34,015]  INFO {org.wso2.andes.server.protocol.AMQProtocolEngine} -  Channel[1] awaiting closure - processing close-ok
[2013-04-02 14:27:34,015]  INFO {org.wso2.andes.server.handler.ChannelCloseOkHandler} -  Received channel-close-ok for channel-id 1
[2013-04-02 14:27:36,424]  INFO {org.wso2.andes.server.store.CassandraMessageStore} -  Removed Global Queue Assigned for Topic Subscription: tmp_1792d33b-7975-44db-b68f-dc54ce9a0852

2 个答案:

答案 0 :(得分:0)

在WSO2 Message Broker中,不会为给定的任何名称动态创建交换。因此,如果主题需要使用“amq.topic”,则预定义的默认主题交换名称为WSO2 MB作为交换名称,如果是队列,则默认交换需要为'amq.direct'以避免此权限问题。

此外,如果需要创建新主题/直接交换(在您的情况下为'texch'),则需要在qpid-virtualhosts.xml文件中预先声明,然后您可以绑定队列/主题进入新的交流。有关此问题的更多指南,请参阅this博文。

答案 1 :(得分:0)

我们必须如下配置quid-virtualhost.xml文件,以便在服务器启动时创建Q.

            <!-- Here you can add remove exchange to this virtualhost-->
            <exchange>
                <type>direct</type>
                <name>carbon.direct</name>
                <durable>true</durable>
            </exchange>
            <exchange>
                <type>topic</type>
                <name>carbon.topic</name>
            </exchange>
        </exchanges>

        <queues>
            <queue>
                <name>TEST</name>
                <TEST>
                    <exchange>carbon.direct</exchange>
                    <durable>true</durable>
                </TEST>
            </queue>

我使用“amqp-ts”发送和接收来自javascripts的消息。

 var amqp = require("amqp-ts");

var connection = new amqp.Connection("amqp://admin:admin@localhost:5672");
//var exchange = connection.declareExchange("carbon.direct",{noCreate: true});
var queue = connection.declareQueue("TEST",{noCreate: true});
//queue.bind(exchange);
queue.activateConsumer((message) => {
    console.log("Message received: " + message.getContent());
});

// it is possible that the following message is not received because
// it can be sent before the queue, binding or consumer exist
var msg = new amqp.Message("Test");
queue.send(msg);

connection.completeConfiguration().then(() => {
    // the following message will be received because
    // everything you defined earlier for this connection now exists
    var msg2 = new amqp.Message("Test2");
    queue.send(msg2);
});

了解更多参考资料https://github.com/squaremo/amqp.node