RabbitMQ - 使用 curl 从队列中获取消息 [英] RabbitMQ - Get messages from a queue using curl

查看:43
本文介绍了RabbitMQ - 使用 curl 从队列中获取消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 rabbitmq 的 HTTP API 从队列中获取一些消息.

I am trying to get a few messages from a queue using the HTTP API of rabbitmq.

我正在关注这里我没有配置 vhost.

I am following the documentation in here I have no vhost configured.

我尝试了以下 curl 命令:

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 然后回答:

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"
"}

你能指出我的错误吗?我怎样才能得到这些消息?

Can you point out my mistake? How can I get these messages?

推荐答案

我设法解决了这个问题.关键:

I managed to solve the problem. The key:

我没有配置虚拟主机.

RabbitMQ 使用/"表示默认 VHOST.

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

"/" 在 HTTP 中被翻译成 %2F...

"/" is translated to %2F in HTTP...

所以正确的调用是:

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆