EventData Class
The EventData class is a container for event content.
- Inheritance
-
builtins.objectEventData
Constructor
EventData(body: str | bytes | List | None = None)
Parameters
Name | Description |
---|---|
body
|
The data to send in a single message. body can be type of str or bytes. Default value: None
|
Examples
Create instances of EventData
from azure.eventhub import EventData
event_data = EventData("String data")
event_data = EventData(b"Bytes data")
Methods
body_as_json |
The content of the event loaded as a JSON object, if the data is compatible. |
body_as_str |
The content of the event as a string, if the data is of a compatible type. |
from_message_content |
Creates an EventData object given content type and a content value to be set as body. |
body_as_json
The content of the event loaded as a JSON object, if the data is compatible.
body_as_json(encoding: str = 'UTF-8') -> Dict[str, Any]
Parameters
Name | Description |
---|---|
encoding
|
The encoding to use for decoding event data. Default is 'UTF-8' Default value: UTF-8
|
Returns
Type | Description |
---|---|
A JSON object. |
body_as_str
The content of the event as a string, if the data is of a compatible type.
body_as_str(encoding: str = 'UTF-8') -> str
Parameters
Name | Description |
---|---|
encoding
|
The encoding to use for decoding event data. Default is 'UTF-8' Default value: UTF-8
|
Returns
Type | Description |
---|---|
The content of the event as a string. |
from_message_content
Creates an EventData object given content type and a content value to be set as body.
from_message_content(content: bytes, content_type: str, **kwargs: Any) -> EventData
Parameters
Name | Description |
---|---|
content
Required
|
The content value to be set as the body of the message. |
content_type
Required
|
The content type to be set on the message. |
Returns
Type | Description |
---|---|
An EventData object. |
Attributes
body
The body of the Message. The format may vary depending on the body type: For DATA, the body could be bytes or Iterable[bytes]. For SEQUENCE, the body could be List or Iterable[List]. For VALUE, the body could be any type.
Returns
Type | Description |
---|---|
int,
bool,
str,
dict,
list,
|
body_type
content_type
The content type descriptor. Optionally describes the payload of the message, with a descriptor following the format of RFC2045, Section 5, for example "application/json". :rtype: str or None
correlation_id
The correlation identifier. Allows an application to specify a context for the message for the purposes of correlation, for example reflecting the MessageId of a message that is being replied to. :rtype: str or None
enqueued_time
message
Get the underlying uamqp.Message or LegacyMessage. This is deprecated and will be removed in a later release.
Returns
Type | Description |
---|---|
<xref:uamqp.Message>,
<xref:LegacyMessage>
|
message_id
The id to identify the message. The message identifier is an application-defined value that uniquely identifies the message and its payload. The identifier is a free-form string and can reflect a GUID or an identifier derived from the application context. If enabled, the duplicate detection feature identifies and removes second and further submissions of messages with the same message id. :rtype: str or None
offset
partition_key
properties
Application-defined properties on the event.
Returns
Type | Description |
---|---|
raw_amqp_message
Advanced usage only. The internal AMQP message payload that is sent or received.
Returns
Type | Description |
---|---|
sequence_number
system_properties
Metadata set by the Event Hubs Service associated with the event.
An EventData could have some or all of the following meta data depending on the source of the event data.
b"x-opt-sequence-number" (int)
b"x-opt-offset" (bytes)
b"x-opt-partition-key" (bytes)
b"x-opt-enqueued-time" (int)
b"message-id" (bytes)
b"user-id" (bytes)
b"to" (bytes)
b"subject" (bytes)
b"reply-to" (bytes)
b"correlation-id" (bytes)
b"content-type" (bytes)
b"content-encoding" (bytes)
b"absolute-expiry-time" (int)
b"creation-time" (int)
b"group-id" (bytes)
b"group-sequence" (bytes)
b"reply-to-group-id" (bytes)
Returns
Type | Description |
---|---|
Azure SDK for Python