otherqueues.rst 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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. Or if you're not using django, but the default loader instead run
  49. ``celeryinit``::
  50. $ celeryinit
  51. Important notes
  52. ---------------
  53. These message queues does not have the concept of exchanges and routing keys,
  54. there's only the queue entity. As a result of this you need to set the
  55. name of the exchange to be the same as the queue::
  56. CELERY_DEFAULT_EXCHANGE = "tasks"
  57. or in a custom queue-mapping:
  58. .. code-block:: python
  59. CELERY_QUEUES = {
  60. "tasks": {"exchange": "tasks"},
  61. "feeds": {"exchange": "feeds"},
  62. }
  63. This isn't a problem if you use the default queue setting, as the default is
  64. already using the same name for queue/exchange.