|
@@ -14,6 +14,69 @@ respective documenation for more information, or contact the `mailinglist`_.
|
|
|
Basics
|
|
|
======
|
|
|
|
|
|
+Automatic routing
|
|
|
+-----------------
|
|
|
+
|
|
|
+The simplest way to do routing is to use the ``CELERY_CREATE_MISSING_QUEUES``
|
|
|
+setting (on by default).
|
|
|
+
|
|
|
+When this setting is on a named queue that is not already defined in
|
|
|
+``CELERY_QUEUES`` will be created automatically. This makes it easy to perform
|
|
|
+simple routing tasks.
|
|
|
+
|
|
|
+Say you have two servers, ``x``, and ``y`` that handles regular tasks,
|
|
|
+and one server ``z``, that only handles feed related tasks, you can use this
|
|
|
+configuration:
|
|
|
+
|
|
|
+ CELERY_ROUTES = {"feed.tasks.import_feed": "feeds"}
|
|
|
+
|
|
|
+With this route enabled import feed tasks will be routed to the
|
|
|
+``"feeds"`` queue, while all other tasks will be routed to the default queue
|
|
|
+(named ``"celery"``, for historic reasons).
|
|
|
+
|
|
|
+Now you can start server ``z`` to only process the feeds queue like this::
|
|
|
+
|
|
|
+ (z)$ celeryd -Q feeds
|
|
|
+
|
|
|
+You can specify as many queues as you want, so you can make this server
|
|
|
+process the default queue as well::
|
|
|
+
|
|
|
+ (z)$ celeryd -Q feeds,celery
|
|
|
+
|
|
|
+Changing the name of the default queue
|
|
|
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
+
|
|
|
+You can change the name of the default queue by using the following
|
|
|
+configuration:
|
|
|
+
|
|
|
+.. code-block:: python
|
|
|
+
|
|
|
+ CELERY_QUEUES = {"default": {"exchange": "default",
|
|
|
+ "binding_key": "default"}}
|
|
|
+ CELERY_DEFAULT_QUEUE = "default"
|
|
|
+
|
|
|
+How the queues are defined
|
|
|
+~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
+
|
|
|
+The point with this feature is to hide the complex AMQP protocol for users
|
|
|
+with only basic needs. However, you may still be interested in how these queues
|
|
|
+are defined.
|
|
|
+
|
|
|
+A queue named ``"video"`` will be created with the following settings:
|
|
|
+
|
|
|
+.. code-block:: python
|
|
|
+
|
|
|
+ {"exchange": "video",
|
|
|
+ "exchange_type": "direct",
|
|
|
+ "routing_key": "video"}
|
|
|
+
|
|
|
+The non-AMQP backends like ``ghettoq`` does not support exchanges, so they
|
|
|
+require the exchange to have the same name as the queue. Using this design
|
|
|
+ensures it will work for them as well.
|
|
|
+
|
|
|
+Manual routing
|
|
|
+--------------
|
|
|
+
|
|
|
Say you have two servers, ``x``, and ``y`` that handles regular tasks,
|
|
|
and one server ``z``, that only handles feed related tasks, you can use this
|
|
|
configuration:
|