otherqueues.rst 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. .. _tut-otherqueues:
  2. ==========================================================
  3. Using Celery with Redis/Database as the messaging queue.
  4. ==========================================================
  5. .. contents::
  6. :local:
  7. .. _otherqueues-redis:
  8. Redis
  9. =====
  10. For the Redis support you have to install the Python redis client::
  11. $ pip install -U redis
  12. .. _otherqueues-redis-conf:
  13. Configuration
  14. -------------
  15. Configuration is easy, set the transport, and configure the location of
  16. your Redis database::
  17. BROKER_TRANSPORT = "redis"
  18. BROKER_HOST = "localhost" # Maps to redis host.
  19. BROKER_PORT = 6379 # Maps to redis port.
  20. BROKER_VHOST = "0" # Maps to database number.
  21. Results
  22. ~~~~~~~
  23. You probably also want to store results in Redis::
  24. CELERY_RESULT_BACKEND = "redis"
  25. REDIS_HOST = "localhost"
  26. REDIS_PORT = 6379
  27. REDIS_DB = 0
  28. For a complete list of options supported by the Redis result backend see
  29. :ref:`conf-redis-result-backend`
  30. If you don't intend to consume results you should disable them::
  31. CELERY_IGNORE_RESULT = True
  32. .. _otherqueues-sqlalchemy:
  33. SQLAlchemy
  34. ==========
  35. .. _otherqueues-sqlalchemy-conf:
  36. For the SQLAlchemy transport you have to install the
  37. `kombu-sqlalchemy` library::
  38. $ pip install -U kombu-sqlalchemy
  39. Configuration
  40. -------------
  41. This transport uses only the :setting:`BROKER_HOST` setting, which have to be
  42. an SQLAlchemy database URI.
  43. #. Set your broker transport::
  44. BROKER_TRANSPORT = "sqlakombu.transport.Transport"
  45. #. Configure the database URI::
  46. BROKER_HOST = "sqlite:///celerydb.sqlite"
  47. Please see `SQLAlchemy: Supported Databases`_ for a table of supported databases.
  48. Some other `SQLAlchemy Connection String`_, examples:
  49. .. code-block:: python
  50. # sqlite (filename)
  51. BROKER_HOST = "sqlite:///celerydb.sqlite"
  52. # mysql
  53. BROKER_HOST = "mysql://scott:tiger@localhost/foo"
  54. # postgresql
  55. BROKER_HOST = "postgresql://scott:tiger@localhost/mydatabase"
  56. # oracle
  57. BROKER_HOST = "oracle://scott:tiger@127.0.0.1:1521/sidname"
  58. .. _`SQLAlchemy: Supported Databases`:
  59. http://www.sqlalchemy.org/docs/core/engines.html#supported-databases
  60. .. _`SQLAlchemy Connection String`:
  61. http://www.sqlalchemy.org/docs/core/engines.html#database-urls
  62. Results
  63. ~~~~~~~
  64. To store results in the database as well, you should configure the result
  65. backend. See :ref:`conf-database-result-backend`.
  66. If you don't intend to consume results you should disable them::
  67. CELERY_IGNORE_RESULT = True
  68. .. _otherqueues-django:
  69. Django Database
  70. ===============
  71. .. _otherqueues-django-conf:
  72. For the Django database transport support you have to install the
  73. `django-kombu` library::
  74. $ pip install -U django-kombu
  75. Configuration
  76. -------------
  77. The database backend uses the Django `DATABASE_*` settings for database
  78. configuration values.
  79. #. Set your broker transport::
  80. BROKER_TRANSPORT = "djkombu.transport.DatabaseTransport"
  81. #. Add :mod:`djkombu` to `INSTALLED_APPS`::
  82. INSTALLED_APPS = ("djkombu", )
  83. #. Verify you database settings::
  84. DATABASE_ENGINE = "mysql"
  85. DATABASE_NAME = "mydb"
  86. DATABASE_USER = "myuser"
  87. DATABASE_PASSWORD = "secret"
  88. The above is just an example, if you haven't configured your database before
  89. you should read the Django database settings reference:
  90. http://docs.djangoproject.com/en/1.1/ref/settings/#database-engine
  91. #. Sync your database schema.
  92. $ python manage.py syncdb