otherqueues.rst 2.4 KB

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