Просмотр исходного кода

Adds Broadcast to routing docs

Ask Solem 14 лет назад
Родитель
Сommit
0f5fe173c4
1 измененных файлов с 27 добавлено и 0 удалено
  1. 27 0
      docs/userguide/routing.rst

+ 27 - 0
docs/userguide/routing.rst

@@ -544,3 +544,30 @@ same behavior:
 
 
 The routers will then be traversed in order, it will stop at the first router
 The routers will then be traversed in order, it will stop at the first router
 returning a true value, and use that as the final route for the task.
 returning a true value, and use that as the final route for the task.
+
+Broadcast
+---------
+
+Celery can also support broadcast routing.
+Here is an example exchange ``bcast`` that uses this:
+
+.. code-block:: python
+
+    from kombu.common import Broadcast
+
+    CELERY_QUEUES = (Broadcast("broadcast_tasks"), )
+
+    CELERY_ROUTES = {"tasks.reload_cache": "broadcast_tasks"}
+
+
+Now the ``tasks.reload_tasks`` task will be sent to every
+worker consuming from this queue.
+
+.. admonition:: Broadcast & Results
+
+    Note that Celery result does not define what happens if two
+    tasks have the same task_id.  If the same task is distributed to more
+    than one worker, then the state history may not be preserved.
+
+    It is a good idea to set the ``task.ignore_result`` attribute in
+    this case.