Message Class

  • java.lang.Object
    • com.microsoft.azure.sdk.iot.device.Message

public class Message

Field Summary

Modifier and Type Field and Description
static final java.nio.charset.Charset DEFAULT_IOTHUB_MESSAGE_CHARSET

Constructor Summary

Constructor Description
Message()

Constructor.

Message(byte[] body)

Constructor.

Message(ByteArrayInputStream stream)

Constructor.

Message(String body)

Constructor.

Method Summary

Modifier and Type Method and Description
java.io.ByteArrayOutputStream getBodyStream()

The stream content of the body.

byte[] getBytes()

The byte content of the body.

java.lang.String getConnectionDeviceId()
java.lang.String getConnectionModuleId()
java.lang.String getContentEncoding()

Returns this message's content encoding.

java.lang.String getContentType()

Return the message's content type.

CorrelatingMessageCallback getCorrelatingMessageCallback()
java.lang.Object getCorrelatingMessageCallbackContext()
java.lang.String getCorrelationId()

Getter for the correlationId property

java.util.Date getCreationTimeUTC()
java.lang.String getCreationTimeUTCString()

Returns the iot hub accepted format for the creation time utc ex: oct 1st, 2018 yields 2008-10-01T17:04:32.0000000

java.lang.String getDeliveryAcknowledgement()

Getter for the delivery acknowledgement system property

java.lang.String getInputName()
IotHubConnectionString getIotHubConnectionString()

Getter for the iotHubConnectionString property

java.lang.String getMessageId()

Getter for the messageId property

MessageType getMessageType()

Getter for the Message type

java.lang.String getOutputName()
MessageProperty[] getProperties()

Returns a copy of the message properties.

java.lang.String getProperty(String name)

Gets the values of user-defined properties of this Message.

java.lang.String getTo()

Getter for the To system property

java.lang.String getUserId()

Getter for the User ID system property

boolean isExpired()

Verifies whether the message is expired or not

boolean isSecurityMessage()
void setAbsoluteExpiryTime(long absoluteTimeout)

Setter for the expiryTime property using absolute time

void setAsSecurityMessage()
void setConnectionDeviceId(String connectionDeviceId)
void setConnectionModuleId(String connectionModuleId)
void setContentEncoding(String contentEncoding)

Set the content encoding of this message.

void setContentType(String contentType)

Deprecated

as of device-client version 1.14.1, please use setContentTypeFinal(String contentType)

Set the content type of this message.

final void setContentTypeFinal(String contentType)

Set the content type of this message.

void setCorrelatingMessageCallback(CorrelatingMessageCallback correlatingMessageCallback)
void setCorrelatingMessageCallbackContext(Object correlatingMessageCallbackContext)
void setCorrelationId(String correlationId)

Setter for the correlationId property

final void setCreationTimeUTC(Date creationTimeUTC)
void setExpiryTime(long timeOut)

Setter for the expiryTime property.

void setInputName(String inputName)

Set the input name of the message, used in routing for module communications

void setIotHubConnectionString(IotHubConnectionString iotHubConnectionString)

Setter for the iotHubConnectionString type

void setMessageId(String messageId)

Setter for the messageId property

void setMessageType(MessageType type)

Setter for the Message type

void setOutputName(String outputName)

Set the output channel name to send to.

void setProperty(String name, String value)

Adds or sets user-defined properties of this Message.

void setUserId(String userId)
java.lang.String toString()

Methods inherited from java.lang.Object

java.lang.Object.clone java.lang.Object.equals java.lang.Object.finalize java.lang.Object.getClass java.lang.Object.hashCode java.lang.Object.notify java.lang.Object.notifyAll java.lang.Object.toString java.lang.Object.wait java.lang.Object.wait java.lang.Object.wait

Field Details

DEFAULT_IOTHUB_MESSAGE_CHARSET

public static final Charset DEFAULT_IOTHUB_MESSAGE_CHARSET

Constructor Details

Message

public Message()

Constructor.

Message

public Message(byte[] body)

Constructor.

Parameters:

body - The body of the new Message instance.

Message

public Message(ByteArrayInputStream stream)

Constructor.

Parameters:

stream - A stream to provide the body of the new Message instance.

Message

public Message(String body)

Constructor.

Parameters:

body - The body of the new Message instance. It is internally serialized to a byte array using UTF-8 encoding.

Method Details

getBodyStream

public ByteArrayOutputStream getBodyStream()

The stream content of the body.

Returns:

always returns null.

getBytes

public byte[] getBytes()

The byte content of the body.

Returns:

A copy of this Message body, as a byte array.

getConnectionDeviceId

public String getConnectionDeviceId()

getConnectionModuleId

public String getConnectionModuleId()

getContentEncoding

public String getContentEncoding()

Returns this message's content encoding. This value is null by default

Returns:

the message's content encoding.

getContentType

public String getContentType()

Return the message's content type. This value is null by default

Returns:

the message's content type

getCorrelatingMessageCallback

public CorrelatingMessageCallback getCorrelatingMessageCallback()

getCorrelatingMessageCallbackContext

public Object getCorrelatingMessageCallbackContext()

getCorrelationId

public String getCorrelationId()

Getter for the correlationId property

Returns:

The property value

getCreationTimeUTC

public Date getCreationTimeUTC()

getCreationTimeUTCString

public String getCreationTimeUTCString()

Returns the iot hub accepted format for the creation time utc ex: oct 1st, 2018 yields 2008-10-01T17:04:32.0000000

Returns:

the iot hub accepted format for the creation time utc

getDeliveryAcknowledgement

public String getDeliveryAcknowledgement()

Getter for the delivery acknowledgement system property

Returns:

the delivery acknowledgement value

getInputName

public String getInputName()

getIotHubConnectionString

public IotHubConnectionString getIotHubConnectionString()

Getter for the iotHubConnectionString property

Returns:

the iotHubConnectionString value

getMessageId

public String getMessageId()

Getter for the messageId property

Returns:

The property value

getMessageType

public MessageType getMessageType()

Getter for the Message type

Returns:

the Message type value

getOutputName

public String getOutputName()

getProperties

public MessageProperty[] getProperties()

Returns a copy of the message properties.

Returns:

a copy of the message properties.

getProperty

public String getProperty(String name)

Gets the values of user-defined properties of this Message.

Parameters:

name - Name of the user-defined property to search for.

Returns:

The value of the property if it is set, or null otherwise.

getTo

public String getTo()

Getter for the To system property

Returns:

the To value

getUserId

public String getUserId()

Getter for the User ID system property

Returns:

the User ID value

isExpired

public boolean isExpired()

Verifies whether the message is expired or not

Returns:

true if the message is expired, false otherwise

isSecurityMessage

public boolean isSecurityMessage()

setAbsoluteExpiryTime

public void setAbsoluteExpiryTime(long absoluteTimeout)

Setter for the expiryTime property using absolute time

Parameters:

absoluteTimeout - The time out for the message, in milliseconds.

setAsSecurityMessage

public void setAsSecurityMessage()

setConnectionDeviceId

public void setConnectionDeviceId(String connectionDeviceId)

Parameters:

connectionDeviceId

setConnectionModuleId

public void setConnectionModuleId(String connectionModuleId)

Parameters:

connectionModuleId

setContentEncoding

public void setContentEncoding(String contentEncoding)

Set the content encoding of this message. Used in message routing.

Parameters:

contentEncoding - the content encoding of the message. May be null if you don't want to specify a content encoding.

setContentType


public void setContentType(String contentType)

Deprecated

as of device-client version 1.14.1, please use setContentTypeFinal(String contentType)

Set the content type of this message. Used in message routing.

Parameters:

contentType - the content type of the message. May be null if you don't want to specify a content type.

setContentTypeFinal

public final void setContentTypeFinal(String contentType)

Set the content type of this message. Used in message routing.

Parameters:

contentType - the content type of the message. May be null if you don't want to specify a content type.

setCorrelatingMessageCallback

public void setCorrelatingMessageCallback(CorrelatingMessageCallback correlatingMessageCallback)

Parameters:

correlatingMessageCallback

setCorrelatingMessageCallbackContext

public void setCorrelatingMessageCallbackContext(Object correlatingMessageCallbackContext)

Parameters:

correlatingMessageCallbackContext

setCorrelationId

public void setCorrelationId(String correlationId)

Setter for the correlationId property

Parameters:

correlationId - The string containing the property value

setCreationTimeUTC

public final void setCreationTimeUTC(Date creationTimeUTC)

Parameters:

creationTimeUTC

setExpiryTime

public void setExpiryTime(long timeOut)

Setter for the expiryTime property. This setter uses relative time, not absolute time.

Parameters:

timeOut - The time out for the message, in milliseconds, from the current time.

setInputName

public void setInputName(String inputName)

Set the input name of the message, used in routing for module communications

Parameters:

inputName - the input channel the message was received from

setIotHubConnectionString

public void setIotHubConnectionString(IotHubConnectionString iotHubConnectionString)

Setter for the iotHubConnectionString type

Parameters:

iotHubConnectionString - The iotHubConnectionString value to set

setMessageId

public void setMessageId(String messageId)

Setter for the messageId property

Parameters:

messageId - The string containing the property value

setMessageType

public void setMessageType(MessageType type)

Setter for the Message type

Parameters:

type - The enum containing the Message type value

setOutputName

public void setOutputName(String outputName)

Set the output channel name to send to. Used in routing for module communications

Parameters:

outputName - the output channel name to send to

setProperty

public void setProperty(String name, String value)

Adds or sets user-defined properties of this Message.

Parameters:

name - Name of the property to be set.
value - Value of the property to be set.

setUserId

public void setUserId(String userId)

Parameters:

userId

toString

public String toString()

Overrides:

Message.toString()

Applies to