bkjones / pyrabbit

A Python module to communicate w/ the RabbitMQ HTTP Management API
http://pyrabbit.readthedocs.org
BSD 3-Clause "New" or "Revised" License
97 stars 86 forks source link

No ability to specify JSON encoding when publishing #5

Closed sergeio closed 11 years ago

sergeio commented 12 years ago

It would be useful to expose the headers of the message when publishing to a queue so that you could specify, for example, that the message encoding is JSON.

bkjones commented 11 years ago

You probably want the AMQP headers exposed, but this 'publish' command doesn't use the AMQP protocol. It's a POST to a web server. Let me know if I've misunderstood, or give me s'more details on the use case so I can be more useful (or submit a pull request!). Here's the doc for the 'publish' endpoint of the HTTP management api that pyrabbit talks to:

Publish a message to a given exchange. You will need a body looking something like:

{"properties":{},"routing_key":"my key","payload":"my body","payload_encoding":"string"}

All keys are mandatory. The payload_encoding key should be either "string" (in which case the payload will be taken to be the UTF-8 encoding of the payload field) or "base64" (in which case the payload field is taken to be base64 encoded). If the message is published successfully, the response will look like:

{"routed": true}

routed will be true if the message was sent to at least one queue.

Please note that the publish / get paths in the HTTP API are intended for injecting test messages, diagnostics etc - they do not implement reliable delivery and so should be treated as a sysadmin's tool rather than a general API for messaging.