otherqueues.rst 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. ==========================================================
  2. Using Celery with Redis/Database as the messaging queue.
  3. ==========================================================
  4. There's a plug-in for celery that enables the use of Redis or an SQL database
  5. as the messaging queue. This is not part of celery itself, but exists as
  6. an extension to `carrot`_.
  7. .. _`carrot`: http://ask.github.com/carrot
  8. .. _`ghettoq`: http://ask.github.com/ghettoq
  9. Installation
  10. ============
  11. You need to install the latest development versions of `carrot`_ and
  12. `ghettoq`_::
  13. $ git clone git://github.com/ask/carrot.git
  14. $ cd carrot
  15. $ python setup.py install
  16. $ git clone git://github.com/ask/ghettoq.git
  17. $ cd ghettoq
  18. $ python setup.py install
  19. Redis
  20. =====
  21. For the Redis support you have to install the Python redis client::
  22. $ pip install redis
  23. Configuration
  24. -------------
  25. Configuration is easy, set the carrot backend, and configure the location of
  26. your Redis database::
  27. CARROT_BACKEND = "ghettoq.taproot.Redis"
  28. BROKER_HOST = "localhost" # Maps to redis host.
  29. BROKER_PORT = 6379 # Maps to redis port.
  30. BROKER_VHOST = "celery" # Maps to database name.
  31. Database
  32. ========
  33. Configuration
  34. -------------
  35. The database backend uses the Django ``DATABASE_*`` settings for database
  36. configuration values.
  37. * Set your carrot backend::
  38. CARROT_BACKEND = "ghettoq.taproot.Database"
  39. * Add ``ghettoq`` to ``INSTALLED_APPS``::
  40. INSTALLED_APPS = ("ghettoq", )
  41. * Sync your database schema.
  42. $ python manage.py syncdb
  43. * Or if you're not using django, but the default loader instead run
  44. ``celeryinit``::
  45. $ celeryinit
  46. Important notes
  47. ---------------
  48. These message queues does not have the concept of exchanges and routing keys,
  49. there's only the queue entity. As a result of this you need to set the
  50. name of the exchange to be the same as the queue::
  51. CELERY_DEFAULT_EXCHANGE = "tasks"
  52. or in a custom queue-mapping:
  53. .. code-block:: python
  54. CELERY_QUEUES = {
  55. "tasks": {"exchange": "tasks"},
  56. "feeds": {"exchange": "feeds"},
  57. }
  58. This isn't a problem if you use the default queue setting, as the default is
  59. already using the same name for queue/exchange.