Share via


Message Class

Definition

The data structure represent the message that is used for interacting with IoT hub.

public sealed class Message : IDisposable
public sealed class Message
type Message = class
    interface IDisposable
type Message = class
Public NotInheritable Class Message
Implements IDisposable
Public NotInheritable Class Message
Inheritance
Message
Implements

Constructors

Message()

Default constructor with no body data.

Message(Byte[])

Creates a telemetry message with the specified payload.

Message(Stream)

Constructor which uses the argument stream as the body stream.

Properties

Ack

Used in cloud-to-device messages to request IoT hub to generate feedback messages as a result of the consumption of the message by the device.

ContentEncoding

Used to specify the content encoding type of the message.

ContentType

Used to specify the content type of the message.

CorrelationId

A string property in a response message that typically contains the MessageId of the request, in request-reply patterns.

CreatedOnUtc

Custom date property set by the originator of the message.

CreationTimeUtc

Custom date property set by the originator of the message.

ExpiresOnUtc

[Optional] The time when this message is considered expired.

ExpiryTimeUtc

[Optional] The time when this message is considered expired.

HasPayload

Indicates if the message has a payload.

LockToken

[Required] LockToken of the received message.

MessageId

[Required for two way requests] Used to correlate two-way communication. Format: A case-sensitive string ( up to 128 char long) of ASCII 7-bit alphanumeric chars

  • {'-', ':', '/', '', '.', '+', '%', '_', '#', '*', '?', '!', '(', ')', ',', '=', '@', ';', '$', '''}. Non-alphanumeric characters are from URN RFC.
MessageSchema

Used to specify the schema of the message content.

Payload

The message payload.

Properties

Gets the dictionary of user properties which are set when user send the data.

To

[Required] Destination of the message.

UserId

[Required in feedback messages] Used to specify the origin of messages generated by device hub. Possible value: “{hub name}/”

Methods

Clone()

Makes a clone of the current event data instance.

Dispose()

Dispose the current event data instance

GetBodyStream()

Return the body stream of the current event data instance

GetBytes()

This methods return the body stream as a byte array

Applies to