How to use curl for a RabbitMQ connection

24 September,2019 by Jack Vamvas

Question : How can I use curl to test a remote  connection to RabbitMQ? The goal is to use Apache Kafka as the end-goal for data streaming from RabbitMQ , but I just want to use a simple curl command line method to establish whether the credentials , host & port are valid. Note this is a remote connection 

Answer: If you have the RabbitMQ queue name and want to return the messages in a queue this method will get the messages. Before attempting the connection ensure the host , username,password, port are all valid. Including making sure is open at the firewall 

 

curl -u guest:guest -i -H "content-type:application/json" -X POST http://127.0.0.1:15672/api/queues/%2F/foo/get -d'{"count":5,"requeue":true,"encoding":"auto","truncate":50000}' 

A common error message is -  there is no valid vhost

RabbitMQ uses the "/" notation for the default VHOST.

"/" is translated to %2F in HTTP. So you'll notice in the url above %2F

 

There is lots of other information you can gather using curl and RabbitMQ, such as the queue size , list of virtual hosts, exchange information

If you're planning on configuring RabbitMQ as a producer in Apache Kafka , you'll need to plan on how you will read the JSON format and depending on  the downward consumer to translate the JSON into a Kafka topic for consumption. 

 

Let me know if you use any other scripting methods for test connections to remote RabbitMQ queues 


Author: Jack Vamvas (http://www.dba-ninja.com)


Share:

Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Working...
Your comment could not be posted. Error type:
Your comment has been posted. Post another comment

The letters and numbers you entered did not match the image. Please try again.

As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

Having trouble reading this image? View an alternate.

Working...

Post a comment on How to use curl for a RabbitMQ connection


dba-ninja.com