فهرست منبع

Adds Broadcast to routing docs

Ask Solem 13 سال پیش
والد
کامیت
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.