Official specification: https://github.com/cloudevents/spec
Types: Integer, String, Binary, Map, Time, URI, Any (can be any of Integer, String, Binary or Map)
An event is a collection of named attributes of the above types:
-
Required:
type
(String),specversion
(String),source
(URI),id
(String) -
Optional:
time
(Time),schemaurl
(URI),contenttype
(String),data
(Any) -
Custom Extensions: defined by an application
The data
attribute carries the "payload" of the event. The other attributes are context (metadata).
The abstract event definition is independent of the format or transport binding used to serialize and deliver them.
- Format
-
Serialize a complete event (context+data) as a sequence of bytes (e.g. JSON, Protocol buffer). Each format is identified by a media type like
application/cloudEvents+json
,application/cloudEvents+proto
- Transport binding
-
Map an event to/from a message defined by some transport (e.g. HTTP, AMQP, MQTT). Bindings can support one or both of the following modes:
- Structured
-
The complete event structure (context + data) is serialized using a known format and stored as the message body. The format media type is stored as message meta-data.
- Binary
-
The binary
data
value becomes the message body. Context attributes (includingcontenttype
) are stored as message meta-data ("headers", "annotations", "properties" or similar). The receiver can access the binary data and context attributes directly, without decoding a format envelope.
Note
|
The format media type is separate from the event’s contenttype. For example an event with contenttype = text/xml could be encoded as application/cloudEvents+json
The receiver decodes the event as JSON, but treats the data attribute as XML.
|
MQTT 3.1.1 transport binding
Structured JSON only. MQTT PUBLISH payload is an application/cloudEvents+json
format event. That’s all folks.
MQTT 5.0 transport binding
- Structured
-
MQTT
Content Type
is anapplication/cloudEvents+
format. NoContent Type
meansapplication/cloudEvents+json
(MQTT 3.1.1 compatible). - Binary
-
-
contenttype== MQTT
Content Type
property (must not be empty or start withapplication/cloudEvents
) -
data
== MQTT binary payload -
Context attributes == MQTT User Properties with the same names
-
AMQP Message mapping
- Structured
-
AMQP
content-type
is anapplication/cloudEvents+
format. Nocontent-type
meansapplication/cloudEvents+json
. - Binary
-
-
contenttype == AMQP
content-type
(must not be empty or start withapplication/cloudEvents
) -
data
== AMQP body (single data section) -
Context attributes == AMQP
application-properties
, attribute names prefixed withcloudEvents:
-