otherqueues.rst 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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://pypi.python.org/pypi/carrot
  8. .. _`ghettoq`: http://pypi.python.org/pypi/ghettoq
  9. .. contents::
  10. :local:
  11. Installation
  12. ============
  13. You need to install the `ghettoq`_ library::
  14. $ pip install -U ghettoq
  15. Redis
  16. =====
  17. For the Redis support you have to install the Python redis client::
  18. $ pip install -U redis
  19. Configuration
  20. -------------
  21. Configuration is easy, set the carrot backend, and configure the location of
  22. your Redis database::
  23. CARROT_BACKEND = "ghettoq.taproot.Redis"
  24. BROKER_HOST = "localhost" # Maps to redis host.
  25. BROKER_PORT = 6379 # Maps to redis port.
  26. BROKER_VHOST = "celery" # Maps to database name.
  27. Database
  28. ========
  29. Configuration
  30. -------------
  31. The database backend uses the Django ``DATABASE_*`` settings for database
  32. configuration values.
  33. #. Set your carrot backend::
  34. CARROT_BACKEND = "ghettoq.taproot.Database"
  35. #. Add ``ghettoq`` to ``INSTALLED_APPS``::
  36. INSTALLED_APPS = ("ghettoq", )
  37. #. Verify you database settings::
  38. DATABASE_ENGINE = "mysql"
  39. DATABASE_NAME = "mydb"
  40. DATABASE_USER = "myuser"
  41. DATABASE_PASSWORD = "secret"
  42. The above is just an example, if you haven't configured your database before
  43. you should read the Django database settings reference:
  44. http://docs.djangoproject.com/en/1.1/ref/settings/#database-engine
  45. #. Sync your database schema.
  46. When using Django::
  47. $ python manage.py syncdb
  48. Important notes
  49. ---------------
  50. These message queues does not have the concept of exchanges and routing keys,
  51. there's only the queue entity. As a result of this you need to set the
  52. name of the exchange to be the same as the queue::
  53. CELERY_DEFAULT_EXCHANGE = "tasks"
  54. or in a custom queue-mapping:
  55. .. code-block:: python
  56. CELERY_QUEUES = {
  57. "tasks": {"exchange": "tasks"},
  58. "feeds": {"exchange": "feeds"},
  59. }
  60. This isn't a problem if you use the default queue setting, as the default is
  61. already using the same name for queue/exchange.