Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make RabbitMQ API calls with vhost "/"?

Tags:

The following API call to RabbitMQ:

http -a USER:PASS localhost:15001/api/queues/

Returns a list of queues:

[
    {
         ...
         "messages_unacknowledged_ram": 0,
         "name": "foo_queue",
         "node": "rabbit@queue-monster-01",
         "policy": "",
         "state": "running",
         "vhost": "/"
     },
     ...
]

Note that the vhost parameter is /.

How do I use a / vhost for the /api/queues/vhost/name call, which returns the details for a specific queue?

I have tried:

  • localhost:15001/api/queues/\//foo_queue
  • localhost:15001/api/queues///foo_queue

But both failed with 404 Object Not Found:

enter image description here

like image 385
Adam Matan Avatar asked Oct 14 '15 07:10

Adam Matan


People also ask

How do I start a vhost in RabbitMQ?

When configuring RabbitMQ, at least one vhost is needed, which in default is just a slash “/”. Vhosts are created through the management portal, through the HTTP API or via rabbitmqctl. View vhosts by entering the admin tab and select the Virtual Hosts. Select the Add New Virtual Host options to create a new vhost.

Why do I get no access to this vhost when trying to start the RabbitMQ?

The error “no access to the vhost” on the RabbitMQ, may happen in case the user which runs the RabbitMQ doesn't have any permissions configured for the vhost used (“/” by default), or in case RabbitMQ wasn't shut down correctly (for example in case we ran out of disk space).

Does RabbitMQ have an API?

The rabbitmq-management plugin provides an HTTP-based API for the management and monitoring of your RabbitMQ server. It enables by default on all CloudAMQP instances and assigned port 443. The full HTTP API reference can be found in the official RabbitMQ Management HTTP API documentation.

Can access virtual hosts RabbitMQ?

Different users can be granted access only to specific virtual hosts. Their permissions in each virtual hosts also can be limited. RabbitMQ supports two major authentication mechanisms as well as several authentication and authorisation backends. Password-based authentication has a companion guide.


1 Answers

URL Encoding did the trick. The URL should be:

localhost:15001/api/queues/%2F/foo_queue
                           ⬆⬆⬆

For the record, I think that REST resources should not be named /, especially not by default.

like image 196
Adam Matan Avatar answered Oct 28 '22 18:10

Adam Matan