public class Message extends Object
Modifier and Type | Field and Description |
---|---|
static Charset |
DEFAULT_IOTHUB_MESSAGE_CHARSET |
Constructor and Description |
---|
Message()
Constructor.
|
Message(byte[] body)
Constructor.
|
Message(ByteArrayInputStream stream)
Constructor.
|
Message(String body)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
ByteArrayOutputStream |
getBodyStream()
The stream content of the body.
|
byte[] |
getBytes()
The byte content of the body.
|
String |
getConnectionDeviceId() |
String |
getConnectionModuleId() |
String |
getContentEncoding()
Returns this message's content encoding.
|
String |
getContentType()
Return the message's content type.
|
String |
getCorrelationId()
Getter for the correlationId property
|
Date |
getCreationTimeUTC() |
String |
getCreationTimeUTCString()
Returns the iot hub accepted format for the creation time utc
ex:
oct 1st, 2018 yields
2008-10-01T17:04:32.0000000
|
String |
getDeliveryAcknowledgement()
Getter for the delivery acknowledgement system property
|
String |
getInputName() |
IotHubConnectionString |
getIotHubConnectionString()
Getter for the iotHubConnectionString property
|
String |
getMessageId()
Getter for the messageId property
|
MessageType |
getMessageType()
Getter for the Message type
|
String |
getOutputName() |
MessageProperty[] |
getProperties()
Returns a copy of the message properties.
|
String |
getProperty(String name)
Gets the values of user-defined properties of this Message.
|
String |
getTo()
Getter for the To system property
|
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) |
void |
setContentTypeFinal(String contentType)
Set the content type of this message.
|
void |
setCorrelationId(String correlationId)
Setter for the correlationId property
|
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) |
String |
toString() |
public static final Charset DEFAULT_IOTHUB_MESSAGE_CHARSET
public Message()
public Message(ByteArrayInputStream stream)
stream
- A stream to provide the body of the new Message instance.public Message(byte[] body)
body
- The body of the new Message instance.public Message(String body)
body
- The body of the new Message instance. It is internally serialized to a byte array using UTF-8 encoding.public ByteArrayOutputStream getBodyStream()
public byte[] getBytes()
public String getProperty(String name)
name
- Name of the user-defined property to search for.public void setProperty(String name, String value)
name
- Name of the property to be set.value
- Value of the property to be set.IllegalArgumentException
- If any of the arguments provided is null.public MessageProperty[] getProperties()
public boolean isExpired()
public String getMessageId()
public void setMessageId(String messageId)
messageId
- The string containing the property valuepublic void setUserId(String userId)
public String getCorrelationId()
public void setCorrelationId(String correlationId)
correlationId
- The string containing the property valuepublic void setExpiryTime(long timeOut)
timeOut
- The time out for the message, in milliseconds, from the current time.public void setAbsoluteExpiryTime(long absoluteTimeout)
absoluteTimeout
- The time out for the message, in milliseconds.public MessageType getMessageType()
public void setConnectionDeviceId(String connectionDeviceId)
public void setConnectionModuleId(String connectionModuleId)
public void setOutputName(String outputName)
outputName
- the output channel name to send topublic void setInputName(String inputName)
inputName
- the input channel the message was received frompublic void setMessageType(MessageType type)
type
- The enum containing the Message type valuepublic String getTo()
public String getConnectionDeviceId()
public String getConnectionModuleId()
public String getInputName()
public String getOutputName()
public String getDeliveryAcknowledgement()
public String getUserId()
public IotHubConnectionString getIotHubConnectionString()
public void setIotHubConnectionString(IotHubConnectionString iotHubConnectionString)
iotHubConnectionString
- The iotHubConnectionString value to setpublic String getContentType()
@Deprecated public void setContentType(String contentType)
setContentTypeFinal(String)
contentType
- the content type of the message. May be null if you don't want to specify a content type.public final void setContentTypeFinal(String contentType)
contentType
- the content type of the message. May be null if you don't want to specify a content type.public String getContentEncoding()
public void setContentEncoding(String contentEncoding)
contentEncoding
- the content encoding of the message. May be null if you don't want to specify a content encoding.public Date getCreationTimeUTC()
public String getCreationTimeUTCString()
public final void setCreationTimeUTC(Date creationTimeUTC)
public void setAsSecurityMessage()
public boolean isSecurityMessage()
Copyright © 2020. All rights reserved.