otherqueues.rst 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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_BACKEND = "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. .. _otherqueues-sqlalchemy:
  22. SQLAlchemy
  23. ==========
  24. .. _otherqueues-sqlalchemy-conf:
  25. For the SQLAlchemy transport you have to install the
  26. `kombu-sqlalchemy` library::
  27. $ pip install -U kombu-sqlalchemy
  28. Configuration
  29. -------------
  30. This transport uses only the :setting:`BROKER_HOST` setting, which have to be
  31. an SQLAlchemy database URI.
  32. #. Set your broker transport::
  33. BROKER_BACKEND = "sqlakombu.transport.Transport"
  34. #. Configure the database URI::
  35. BROKER_HOST = "sqlite://celerydb.sqlite"
  36. Please see `SQLAlchemy: Supported Databases`_ for a table of supported databases.
  37. Some other `SQLAlchemy Connection String`_, examples:
  38. .. code-block:: python
  39. # sqlite (filename)
  40. BROKER_HOST = "sqlite:///celerydb.sqlite"
  41. # mysql
  42. BROKER_HOST = "mysql://scott:tiger@localhost/foo"
  43. # postgresql
  44. BROKER_HOST = "postgresql://scott:tiger@localhost/mydatabase"
  45. # oracle
  46. BROKER_HOST = "oracle://scott:tiger@127.0.0.1:1521/sidname"
  47. .. _`SQLAlchemy: Supported Databases`:
  48. http://www.sqlalchemy.org/docs/dbengine.html#supported-databases
  49. .. _`SQLAlchemy Connection String`:
  50. http://www.sqlalchemy.org/docs/dbengine.html#create-engine-url-arguments
  51. .. _otherqueues-django:
  52. Django Database
  53. ===============
  54. .. _otherqueues-django-conf:
  55. For the Django database transport support you have to install the
  56. `django-kombu` library::
  57. $ pip install -U django-kombu
  58. Configuration
  59. -------------
  60. The database backend uses the Django `DATABASE_*` settings for database
  61. configuration values.
  62. #. Set your broker transport::
  63. BROKER_BACKEND = "djkombu.transport.DatabaseTransport"
  64. #. Add :mod:`djkombu` to `INSTALLED_APPS`::
  65. INSTALLED_APPS = ("djkombu", )
  66. #. Verify you database settings::
  67. DATABASE_ENGINE = "mysql"
  68. DATABASE_NAME = "mydb"
  69. DATABASE_USER = "myuser"
  70. DATABASE_PASSWORD = "secret"
  71. The above is just an example, if you haven't configured your database before
  72. you should read the Django database settings reference:
  73. http://docs.djangoproject.com/en/1.1/ref/settings/#database-engine
  74. #. Sync your database schema.
  75. $ python manage.py syncdb