【问题标题】:"Not found" returned when creating RabbitMQ queue using rabbitmqadmin使用 rabbitmqadmin 创建 RabbitMQ 队列时返回“未找到”
【发布时间】:2021-04-23 14:04:12
【问题描述】:

我需要从命令行创建一个 RabbitMQ 队列。

  1. 我在 kubernetes 中有一个 RabbitMQ 设置。
  2. 我登录到 RabbitMQ pod 并为我的 3.8.14 版本获取 rabbitmqadmin
  3. 我运行这个:

./rabbitmqadmin -u user1 -p password1 -N rabbit@rabbitmq-0.rabbitmq.default.svc.cluster.local declare queue name=CompName.Player1

但我得到的不是添加队列:

**未找到:/api/queues/%2F/CompName.Player1

我尝试了这些但没有成功,运行这些 rabbitmqadmin 命令时,rabbitmq 日志也没有显示任何事件:

./rabbitmqadmin declare queue name=Test1

./rabbitmqadmin -u user1 -p password1 declare queue name=CompName.Player1

curl -i -u user1:password1 -H "content-type:application/json" -XPUT -d'{"durable":true}' http://localhost:15672/api/queues/%2f/CompName.Player1

通过管理 Web UI 手动添加队列是可行的,但这不是 kubernetes 解决方案的选项。

【问题讨论】:

    标签: kubernetes rabbitmq rabbitmqadmin


    【解决方案1】:

    我明白了。我认为在某个时候 API 端点已更新,因此所有调用都必须转到 http://localhost:15672/rabbitmq/api。以下是添加的导致问题的配置行:

    management.path_prefix = /rabbitmq
    

    以下是工作示例:

    ./rabbitmqadmin -u user1 -p password1 --path-prefix=http://localhost:15672/rabbitmq declare queue name=CompName.Player1

    curl -i -u user1:password1 -H "content-type:application/json" -XPUT -d'{"durable":true}' http://localhost:15672/rabbitmq/api/queues/%2f/CompName.Player1

    这也有效:

    import pika
    import sys
    connection = pika.BlockingConnection(
        pika.ConnectionParameters(host='localhost'))
    channel = connection.channel()
    channel.queue_declare(queue='CompName.Player1', durable=True)
    connection.close()```
    

    【讨论】:

      猜你喜欢
      • 2014-02-11
      • 1970-01-01
      • 2023-03-28
      • 2020-04-10
      • 2015-06-16
      • 2018-04-08
      • 2023-03-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多