RabbitMQ is a message broker that allows clients to connect over different open and standardized protocols such as AMQP, HTTP, STOMP, MQTT, MQTT over WebSockets and STOMP over WebSockets.

HTTP stands for Hypertext Transfer Protocol, and it is an application-level protocol for distributed, collaborative, hypermedia information systems. HTTP is not a messaging protocol. However, RabbitMQ can transmit messages over HTTP.

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.

Publish with HTTP

Example of how to publish a message to the default exchange with the routing key my_key:

curl -XPOST -d'{"properties":{},"routing_key":"my_key","payload":"my body","payload_encoding":"string"}' https://username:password@hostname/api/exchanges/vhost/amq.default/publish

Respons: {"routed":true}

Get message with HTTP

Example of how to get one message from the Queue your_queue . (This is not an HTTP GET as it will alter the Queue’s state.)

curl -XPOST -d'{"count":1,"requeue":true,"encoding":"auto"}' https://username:password@hostname/api/queues/your_vhost/your_queue/get

Respons: JSON message with payload and properties.

Get queue information

curl -XGET https://username:password@hostname/api/queues/your_vhost/your_queue

Respons: JSON message with queue information.

Autoscale by polling queue length

When arrive faster to the queue than they are processed - and when the queue starts growing in length, it is good to spin up more workers. The idea is to poll the HTTP API queue length and spin up or take down workers depending on the length.