RabbitMQ Management HTTP API--官方文档

Introduction

Apart from this help page, all URIs will serve only resources of type application/json, and will require HTTP basic authentication (using the standard RabbitMQ user database). The default user is guest/guest.

Many URIs require the name of a virtual host as part of the path, since names only uniquely identify objects within a virtual host. As the default virtual host is called "/", this will need to be encoded as "%2f".

PUTing a resource creates it. The JSON object you upload must have certain keys (documented below). Other keys are ignored. Missing keys consitute an error.

Since bindings do not have names or IDs in AMQP we synthesise one based on all its properties. Since predicting this name is hard in the general case, you can also create bindings by POSTing to a factory URI. See the example below.

Caveats

These caveats apply to the current development version of the management API. In future they will be fixed.

  • arguments fields are ignored everywhere. You cannot create a queue, exchange or binding with arguments. Queues, exchanges or bindings with arguments won't show those arguments.
  • Permissions are only enforced sporadically. If a user can authenticate with the HTTP API, they can do anything.
  • There are many monitoring-related information items in the objects returned from GET requests. They are undocumented and subject to change.

Examples

A few quick examples, using the Unix command line tool curl:

  • Get a list of vhosts:
    $ curl -i -u guest:guest http://localhost:55672/api/vhosts
    HTTP/1.1 200 OK
    Server: MochiWeb/1.1 WebMachine/1.7 (participate in the frantic)
    Date: Tue, 31 Aug 2010 15:46:59 GMT
    Content-Type: application/json
    Content-Length: 5
    
    ["/"]
  • Create a new vhost:
    $ curl -i -u guest:guest -H "content-type:application/json" \
      -XPUT http://localhost:55672/api/vhosts/foo
    HTTP/1.1 204 No Content
    Server: MochiWeb/1.1 WebMachine/1.7 (participate in the frantic)
    Date: Fri, 27 Aug 2010 16:56:00 GMT
    Content-Type: application/json
    Content-Length: 0

    Note: you must specify application/json as the mime type.

    Note: the name of the object is not needed in the JSON object uploaded, since it is in the URI. As a virtual host has no properties apart from its name, this means you do not need to specify a body at all!

  • Create a new exchange in the default virtual host:
    $ curl -i -u guest:guest -H "content-type:application/json" \
      -XPUT -d'{"type":"direct","auto_delete":false,"durable":true,"arguments":[]}' \
      http://localhost:55672/api/exchanges/%2f/my-new-exchange
    HTTP/1.1 204 No Content
    Server: MochiWeb/1.1 WebMachine/1.7 (participate in the frantic)
    Date: Fri, 27 Aug 2010 17:04:29 GMT
    Content-Type: application/json
    Content-Length: 0

    Note: we never return a body in response to a PUT or DELETE, unless it fails.

  • And delete it again:
    $ curl -i -u guest:guest -H "content-type:application/json" \
      -XDELETE http://localhost:55672/api/exchanges/%2f/my-new-exchange
    HTTP/1.1 204 No Content
    Server: MochiWeb/1.1 WebMachine/1.7 (participate in the frantic)
    Date: Fri, 27 Aug 2010 17:05:30 GMT
    Content-Type: application/json
    Content-Length: 0

Reference

GETPUTDELETEPOSTPathDescription
X   /api/overviewVarious random bits of information that describe the whole system.
X   /api/connectionsA list of all open connections.
X X /api/connections/nameAn individual connection. DELETEing it will close the connection.
X   /api/channelsA list of all open channels.
X   /api/channels/channelDetails about an individual channel.
X   /api/exchangesA list of all exchanges.
X   /api/exchanges/vhostA list of all exchanges in a given virtual host.
XXX /api/exchanges/vhost/nameAn individual exchange. To PUT an exchange, you will need a body looking something like this:
{"type":"direct","auto_delete":false,"durable":true,"arguments":[]}
X   /api/exchanges/vhost/name/bindingsA list of all bindings on a given exchange.
X   /api/queuesA list of all queues.
X   /api/queues/vhostA list of all queues in a given virtual host.
XXX /api/queues/vhost/nameAn individual queue. To PUT a queue, you will need a body looking something like this:
{"auto_delete":false,"durable":true,"arguments":[]}
X   /api/queues/vhost/queue/bindingsA list of all bindings on a given queue.
X   /api/bindingsA list of all bindings.
X   /api/bindings/vhostA list of all bindings in a given virtual host.
X  X/api/bindings/vhost/queue/exchangeA list of all bindings between a queue and an exchange. Remember, a queue and an exchange can be bound together many times! To create a new binding, POST to this URI. You will need a body looking something like this:
{"routing_key":"my_routing_key","arguments":[]}
The response will contain a Location header telling you the URI of your new binding.
XXX /api/bindings/vhost/queue/exchange/propsAn individual binding between a queue and an exchange. The props part of the URI is a "name" for the binding composed of its routing key and properties. While you can create a binding by PUTing to this URI, it may be more convenient to POST to the URI above.
X   /api/vhostsA list of all vhosts.
XXX /api/vhosts/nameAn individual virtual host. As a virtual host only has a name, you do not need an HTTP body when PUTing one of these.
X   /api/usersA list of all users.
XXX /api/users/nameAn individual user. To PUT a user, you will need a body looking something like this:
{"password":"secret"}
X   /api/users/user/permissionsA list of all permissions for a given user.
X   /api/permissionsA list of all permissions for all users.
XXX /api/permissions/vhost/userAn individual permission of a user and virtual host. To PUT a permission, you will need a body looking something like this:
{"scope":"client","configure":".*","write":".*","read":".*"}

 

原文地址:http://hg.rabbitmq.com/rabbitmq-management/raw-file/3646dee55e02/priv/www-api/help.html

 

转载于:https://www.cnblogs.com/davidwang456/p/4062020.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值