RabbitMQ-使用curl从队列中获取消息 [英] RabbitMQ - Get messages from a queue using curl
本文介绍了RabbitMQ-使用curl从队列中获取消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用Rabbitmq的HTTP API从队列中获取一些消息.
我正在
"/"在HTTP中转换为%2F
...
因此正确的呼叫是:
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}'
I am trying to get a few messages from a queue using the HTTP API of rabbitmq.
I am following the documentation in here
I have no vhost
configured.
I tried the following curl command:
curl -i -u guest:guest -H "content-type:application/json" -X POST http://127.0.0.1:15672/api/queues/foo/get -d'{"count":5,"requeue":true,"encoding":"auto","truncate":50000}'
RabbitMQ then answers:
HTTP/1.1 405 Method Not Allowed
vary: origin
Server: MochiWeb/1.1 WebMachine/1.10.0 (never breaks eye contact)
Date: Thu, 20 Apr 2017 08:03:28 GMT
Content-Length: 66
Allow: HEAD, GET, PUT, DELETE, OPTIONS
{"error":"Method Not Allowed","reason":"\"Method Not Allowed\"\n"}
Can you point out my mistake? How can I get these messages?
解决方案
I managed to solve the problem. The key:
I have no vhost configured.
RabbitMQ uses the "/" notation for the default VHOST.
"/" is translated to %2F
in HTTP...
So the correct call is:
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}'
这篇关于RabbitMQ-使用curl从队列中获取消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文