"Not found" returned when creating RabbitMQ queue using rabbitmqadmin

1.3k views Asked by At

I need to create a RabbitMQ queue from command line.

  1. I have a RabbitMQ setup in kubernetes.
  2. I login into a RabbitMQ pod and fetch the rabbitmqadmin for my version 3.8.14
  3. I run this:

./rabbitmqadmin -u user1 -p password1 -N [email protected] declare queue name=CompName.Player1

But instead of adding the queue I get:

**Not found: /api/queues/%2F/CompName.Player1

I tried these but had no success, also the rabbitmq log shows no events when running these rabbitmqadmin commands:

./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

Adding the queue manually via management web UI works but it's not an option for a kubernetes solution.

2

There are 2 answers

0
Vladimir On

I got it. I think at some point the API endpoint got updated so all calls must go to http://localhost:15672/rabbitmq/api. Here's the configuration line that was added that caused the issues:

management.path_prefix = /rabbitmq

Here are the working examples:

./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

Also this worked:

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

Had a similar issue, I just renamed the un-URL-friendly default vhost name / to something else, such as default, and it worked like charm after that.

Something might not like the URL-escaped slash, %2F...

You can declare your vhosts in a RabbitMQ json definition file like this:

{
  "rabbit_version": "3.12.12",
  "rabbitmq_version": "3.12.12",
  "product_name": "RabbitMQ",
  "product_version": "3.12.12",
  /* ... */
  "vhosts": [
    {
      "name": "default"
    }
  ],
  "queues": [
    {
      "name": "CompName.Player1",
      "vhost": "default",
      "durable": true,
      "auto_delete": false,
      "arguments": {}
    }
  ]
  /* ... */
}

And reference that definitions.json in /etc/rabbitmq/rabbitmq.conf:

load_definitions = /etc/rabbitmq/definitions.json