Message Class

Definition

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

public sealed class Message : IDisposable, Microsoft.Azure.Devices.Client.IReadOnlyIndicator
type Message = class
    interface IReadOnlyIndicator
    interface IDisposable
Public NotInheritable Class Message
Implements IDisposable, IReadOnlyIndicator
Inheritance
Message
Implements

Constructors

Message()

Default constructor with no body data

Message(Byte[])

Constructor which uses the input byte array as the body.

Message(Stream)

Constructor which uses the argument stream as the body stream.

Properties

BodyStream

The body stream of the current event data instance

ComponentName

The DTDL component name from where the telemetry message has originated. This is relevant only for plug and play certified devices.

ConnectionDeviceId

Specifies the device Id from which this message was sent, if there is one.

ConnectionModuleId

Specifies the module Id from which this message was sent, if there is one.

ContentEncoding

Used to specify the content encoding type of the message.

ContentType

Used to specify the content type of the message.

CorrelationId

Used in message responses and feedback

CreationTimeUtc

Custom date property set by the originator of the message.

DeliveryCount

Number of times the message has been previously delivered

EnqueuedTimeUtc

Date and time when the device-to-cloud message was received by the server.

ExpiryTimeUtc

[Optional] The time when this message is considered expired

InputName

Specifies the input name on which the message was sent, if there was one.

IsSecurityMessage

True if the message is set as a security message

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.

Properties

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

SequenceNumber

[Required] SequenceNumber of the received message

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

CloneWithBody(Byte[])

Clones an existing Message instance and sets content body defined by byteArray on it.

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

SetAsSecurityMessage()

Sets the message as an security message

Explicit Interface Implementations

IReadOnlyIndicator.IsReadOnly

Applies to