protocol.rst 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. .. _internals-task-message-protocol:
  2. =======================
  3. Task Message Protocol
  4. =======================
  5. .. contents::
  6. :local:
  7. Message format
  8. ==============
  9. * task
  10. `string`
  11. Name of the task. **required**
  12. * id
  13. `string`
  14. Unique id of the task (UUID). **required**
  15. * args
  16. `list`
  17. List of arguments. Will be an empty list if not provided.
  18. * kwargs
  19. `dictionary`
  20. Dictionary of keyword arguments. Will be an empty dictionary if not
  21. provided.
  22. * retries
  23. `int`
  24. Current number of times this task has been retried.
  25. Defaults to `0` if not specified.
  26. * eta
  27. `string` (ISO 8601)
  28. Estimated time of arrival. This is the date and time in ISO 8601
  29. format. If not provided the message is not scheduled, but will be
  30. executed asap.
  31. * expires (introduced after v2.0.2)
  32. `string` (ISO 8601)
  33. Expiration date. This is the date and time in ISO 8601 format.
  34. If not provided the message will never expire. The message
  35. will be expired when the message is received and the expiration date
  36. has been exceeded.
  37. Extensions
  38. ==========
  39. Extensions are additional keys in the message body that the worker may or
  40. may not support. If the worker finds an extension key it doesn't support
  41. it should optimally reject the message so another worker gets a chance
  42. to process it.
  43. * taskset_id
  44. The taskset this task is part of.
  45. * chord
  46. Siginifies that this task is one of the header parts of a chord. The value
  47. of this key is the body of the cord that should be executed when all of
  48. the tasks in the header has returned.
  49. Example message
  50. ===============
  51. This is an example invocation of the `celery.task.PingTask` task in JSON
  52. format:
  53. .. code-block:: javascript
  54. {"id": "4cc7438e-afd4-4f8f-a2f3-f46567e7ca77",
  55. "task": "celery.task.PingTask",
  56. "args": [],
  57. "kwargs": {},
  58. "retries": 0,
  59. "eta": "2009-11-17T12:30:56.527191"}
  60. Serialization
  61. =============
  62. The protocol supports several serialization formats using the
  63. `content_type` message header.
  64. The MIME-types supported by default are shown in the following table.
  65. =============== =================================
  66. Scheme MIME Type
  67. =============== =================================
  68. json application/json
  69. yaml application/x-yaml
  70. pickle application/x-python-serialize
  71. msgpack application/x-msgpack
  72. =============== =================================