DESCRIPTION.rst 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. ================================================================
  2. librabbitmq - Python AMQP Client using the rabbitmq-c library.
  3. ================================================================
  4. :Version: 1.6.0
  5. :Download: http://pypi.python.org/pypi/librabbitmq/
  6. :Code: http://github.com/celery/librabbitmq/
  7. :Keywords: rabbitmq, amqp, messaging, librabbitmq, rabbitmq-c, python,
  8. kombu, celery
  9. .. contents::
  10. :local:
  11. Python bindings to the RabbitMQ C-library `rabbitmq-c`_.
  12. Supported by Kombu and Celery.
  13. .. _`rabbitmq-c`: https://github.com/alanxz/rabbitmq-c
  14. Installation
  15. ============
  16. Install via pip::
  17. $ pip install librabbitmq
  18. or, install via easy_install::
  19. $ easy_install librabbitmq
  20. Downloading and installing from source
  21. --------------------------------------
  22. Download the latest version from
  23. http://pypi.python.org/pypi/librabbitmq/
  24. Then install it by doing the following,::
  25. $ tar xvfz librabbitmq-0.0.0.tar.gz
  26. $ cd librabbitmq-0.0.0
  27. $ python setup.py build
  28. # python setup.py install # as root
  29. Using the development version
  30. -----------------------------
  31. You can clone the repository by doing the following::
  32. $ git clone git://github.com/celery/librabbitmq.git
  33. Then install it by doing the following::
  34. $ cd librabbitmq
  35. $ make install # or make develop
  36. Examples
  37. ========
  38. Using with Kombu::
  39. >>> from kombu import Connection
  40. >>> x = Connection("librabbitmq://")
  41. Stand-alone::
  42. >>> from librabbitmq import Connection
  43. >>> conn = Connection(host="localhost", userid="guest",
  44. ... password="guest", virtual_host="/")
  45. >>> channel = conn.channel()
  46. >>> channel.exchange_declare(exchange, type, ...)
  47. >>> channel.queue_declare(queue, ...)
  48. >>> channel.queue_bind(queue, exchange, routing_key)
  49. Producing
  50. ---------
  51. ::
  52. >>> channel.basic_publish(body, exchange, routing_key, ...)
  53. Consuming
  54. ---------
  55. ::
  56. >>> def dump_message(message):
  57. ... print("Body:'%s', Proeprties:'%s', DeliveryInfo:'%s'" % (
  58. ... message.body, message.properties, message.delivery_info))
  59. ... message.ack()
  60. >>> channel.basic_consume(queue, ..., callback=dump_message)
  61. >>> while True:
  62. ... connection.drain_events()
  63. Poll
  64. ----
  65. ::
  66. >>> message = channel.basic_get(queue, ...)
  67. >>> if message:
  68. ... dump_message(message)
  69. ... print("Body:'%s' Properties:'%s' DeliveryInfo:'%s'" % (
  70. ... message.body, message.properties, message.delivery_info))
  71. Other
  72. -----
  73. ::
  74. >>> channel.queue_unbind(queue, ...)
  75. >>> channel.close()
  76. >>> connection.close()
  77. License
  78. =======
  79. This software is licensed under the ``Mozilla Public License``.
  80. See the ``LICENSE-MPL-RabbitMQ`` file in the top distribution directory
  81. for the full license text.
  82. .. # vim: syntax=rst expandtab tabstop=4 shiftwidth=4 shiftround