otherqueues.rst 2.9 KB

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