【问题标题】:Permission Denied when using AMQP 0-9-1 with WSO2 MB将 AMQP 0-9-1 与 WSO2 MB 一起使用时权限被拒绝
【发布时间】:2016-12-19 13:04:33
【问题描述】:

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

具体来说,我的代码正在尝试使用路由键“rkey”发布到交换“texch”,并通过运行时创建的队列使用消息,该队列绑定到“texch”,路由键为“rkey”。

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

【问题讨论】:

    标签: wso2 amqp


    【解决方案1】:

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

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

    【讨论】:

      【解决方案2】:

      我们必须如下配置 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

      【讨论】:

        猜你喜欢
        • 2020-03-29
        • 2020-01-25
        • 1970-01-01
        • 2022-06-11
        • 2019-07-13
        • 2021-08-03
        • 2023-03-26
        • 2018-02-14
        相关资源
        最近更新 更多