otherqueues.rst 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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_URL = "redis://localhost:6379/0"
  18. Where the URL is in the format of::
  19. redis://userid:password@hostname:port/db_number
  20. Results
  21. ~~~~~~~
  22. You probably also want to store results in Redis::
  23. CELERY_RESULT_BACKEND = "redis"
  24. CELERY_REDIS_HOST = "localhost"
  25. CELERY_REDIS_PORT = 6379
  26. CELERY_REDIS_DB = 0
  27. For a complete list of options supported by the Redis result backend see
  28. :ref:`conf-redis-result-backend`
  29. If you don't intend to consume results you should disable them::
  30. CELERY_IGNORE_RESULT = True
  31. .. _otherqueues-sqlalchemy:
  32. SQLAlchemy
  33. ==========
  34. .. _otherqueues-sqlalchemy-conf:
  35. For the SQLAlchemy transport you have to install the
  36. `kombu-sqlalchemy` library::
  37. $ pip install -U kombu-sqlalchemy
  38. Configuration
  39. -------------
  40. This transport uses only the :setting:`BROKER_HOST` setting, which have to be
  41. an SQLAlchemy database URI.
  42. #. Set your broker transport::
  43. BROKER_TRANSPORT = "sqlalchemy"
  44. #. Configure the database URI::
  45. BROKER_HOST = "sqlite:///celerydb.sqlite"
  46. Please see `SQLAlchemy: Supported Databases`_ for a table of supported databases.
  47. Some other `SQLAlchemy Connection String`_, examples:
  48. .. code-block:: python
  49. # sqlite (filename)
  50. BROKER_HOST = "sqlite:///celerydb.sqlite"
  51. # mysql
  52. BROKER_HOST = "mysql://scott:tiger@localhost/foo"
  53. # postgresql
  54. BROKER_HOST = "postgresql://scott:tiger@localhost/mydatabase"
  55. # oracle
  56. BROKER_HOST = "oracle://scott:tiger@127.0.0.1:1521/sidname"
  57. .. _`SQLAlchemy: Supported Databases`:
  58. http://www.sqlalchemy.org/docs/core/engines.html#supported-databases
  59. .. _`SQLAlchemy Connection String`:
  60. http://www.sqlalchemy.org/docs/core/engines.html#database-urls
  61. Results
  62. ~~~~~~~
  63. To store results in the database as well, you should configure the result
  64. backend. See :ref:`conf-database-result-backend`.
  65. If you don't intend to consume results you should disable them::
  66. CELERY_IGNORE_RESULT = True
  67. .. _otherqueues-django:
  68. Django Database
  69. ===============
  70. .. _otherqueues-django-conf:
  71. For the Django database transport support you have to install the
  72. `django-kombu` library::
  73. $ pip install -U django-kombu
  74. Configuration
  75. -------------
  76. The database backend uses the Django `DATABASE_*` settings for database
  77. configuration values.
  78. #. Set your broker transport::
  79. BROKER_TRANSPORT = "django"
  80. #. Add :mod:`djkombu` to `INSTALLED_APPS`::
  81. INSTALLED_APPS = ("djkombu", )
  82. #. Verify you database settings::
  83. DATABASE_ENGINE = "mysql"
  84. DATABASE_NAME = "mydb"
  85. DATABASE_USER = "myuser"
  86. DATABASE_PASSWORD = "secret"
  87. The above is just an example, if you haven't configured your database before
  88. you should read the Django database settings reference:
  89. http://docs.djangoproject.com/en/1.1/ref/settings/#database-engine
  90. #. Sync your database schema.
  91. $ python manage.py syncdb