routing.rst 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. ===============
  2. Routing Tasks
  3. ===============
  4. **NOTE** This document refers to functionality only available in brokers
  5. using AMQP. Other brokers may implement some functionality, see their
  6. respective documenation for more information, or contact the `mailinglist`_.
  7. .. _`mailinglist`: http://groups.google.com/group/celery-users
  8. AMQP Primer
  9. ===========
  10. Exchanges, queues and routing keys.
  11. -----------------------------------
  12. TODO Mindblowing one-line simple explanation here. TODO
  13. Exchange type
  14. -------------
  15. The exchange type defines how the messages are routed through the exchange.
  16. The exchanges defined in the standard is ``direct``, ``topic``, ``fanout`` and
  17. ``headers``. Also non-standard exchange types available as plugins to RabbitMQ, like
  18. the last value cache plug-in.
  19. Consumers and Producers
  20. -----------------------
  21. TODO
  22. Related API commands
  23. -------------------------
  24. * exchange.declare(exchange_name, type, passive, durable, auto_delete, internal)
  25. Declares an exchange by name.
  26. * ``passive`` means the exchange won't be created, but you can use this to
  27. check if the exchange already exists.
  28. * Durable exchanges are persistent. I.e. they survive a broker restart.
  29. * ``auto_delete`` means the queue will be deleted by the broker when there
  30. are no more queues using it.
  31. * queue.declare(queue_name, passive, durable, exclusive, auto_delete)
  32. Declares a queue by name.
  33. * exclusive queues can only be consumed from by the current connection.
  34. implies ``auto_delete``.
  35. * queue.bind(queue_name, exchange_name, routing_key)
  36. Binds a queue to an exchange with a routing key.
  37. Unbound queues will not receive messages, so this is necessary.
  38. * queue.delete(name, if_unused, if_empty)
  39. Deletes a queue and its binding.
  40. * exchange.delete(name, if_unused)
  41. Deletes an exchange.
  42. **NOTE**: Declaring does not necessarily mean "create". When you declare you
  43. *assert* that the entity exists and it is operable. There is no rule as to
  44. whom should initially create the exchange/queue/binding, whether consumer
  45. or producer. Usually the first one to need it will create it.
  46. Hands-on with the API
  47. ---------------------
  48. Celery comes with a tool called ``camqadm`` (short for celery AMQP admin).
  49. It's used for simple admnistration tasks like deleting queues/exchanges,
  50. purging queues and creating queue entities. In short it's for simple command
  51. line access to the AMQP API.