otherqueues.rst 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. .. _tut-otherqueues:
  2. ==========================================================
  3. Using Celery with Redis/Database as the messaging queue.
  4. ==========================================================
  5. There's a plug-in for celery that enables the use of Redis or an SQL database
  6. as the messaging queue. This is not part of celery itself, but exists as
  7. an extension to `carrot`_.
  8. .. _`carrot`: http://pypi.python.org/pypi/carrot
  9. .. _`ghettoq`: http://pypi.python.org/pypi/ghettoq
  10. .. contents::
  11. :local:
  12. .. _otherqueues-installation:
  13. Installation
  14. ============
  15. You need to install the `ghettoq`_ library::
  16. $ pip install -U ghettoq
  17. .. _otherqueues-redis:
  18. Redis
  19. =====
  20. For the Redis support you have to install the Python redis client::
  21. $ pip install -U redis
  22. .. _otherqueues-redis-conf:
  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. .. _otherqueues-database:
  32. Database
  33. ========
  34. .. _otherqueues-database-conf:
  35. Configuration
  36. -------------
  37. The database backend uses the Django ``DATABASE_*`` settings for database
  38. configuration values.
  39. #. Set your carrot backend::
  40. CARROT_BACKEND = "ghettoq.taproot.Database"
  41. #. Add :mod:`ghettoq` to ``INSTALLED_APPS``::
  42. INSTALLED_APPS = ("ghettoq", )
  43. #. Verify you database settings::
  44. DATABASE_ENGINE = "mysql"
  45. DATABASE_NAME = "mydb"
  46. DATABASE_USER = "myuser"
  47. DATABASE_PASSWORD = "secret"
  48. The above is just an example, if you haven't configured your database before
  49. you should read the Django database settings reference:
  50. http://docs.djangoproject.com/en/1.1/ref/settings/#database-engine
  51. #. Sync your database schema.
  52. When using Django::
  53. $ python manage.py syncdb
  54. .. _otherqueues-notes:
  55. Important notes
  56. ---------------
  57. These message queues does not have the concept of exchanges and routing keys,
  58. there's only the queue entity. As a result of this you need to set the
  59. name of the exchange to be the same as the queue::
  60. CELERY_DEFAULT_EXCHANGE = "tasks"
  61. or in a custom queue-mapping:
  62. .. code-block:: python
  63. CELERY_QUEUES = {
  64. "tasks": {"exchange": "tasks"},
  65. "feeds": {"exchange": "feeds"},
  66. }
  67. This isn't a problem if you use the default queue setting, as the default is
  68. already using the same name for queue/exchange.