com.apama.cumulocity.devices
Event DeviceMessage


This event carries the DeviceMessage information (i.e. payload and properties/metadata). Used for bidirectional communication to send messages to-device and receive messages from-device.

Note: The DeviceMessage is currently in public preview and may be subject to change in future.
Field summary
 stringtransportID

The transport identifier (e.g., "mqtt").
 stringclientID

The client identifier from the transport.
 stringtopic

The topic or destination identifier.
 dictionary<stringany>transportProperties

Transport-specific properties as key-value pairs.
 floattime

The timestamp when the message was received from the device.
 
Action summary
 voidencodeJSONPayload(any object)

Converts an object to a JSON string and stores it as the payload.
 stringgetBinaryBase64Payload()

Returns the payload encoded as a Base64 string.
 stringgetStringPayload()

Decodes the payload as a UTF-8 string.
 anyparseJSONPayload()

Decodes the payload as a UTF-8 string, then parses that string as JSON.
 voidsetBinaryBase64Payload(string base64)

Sets the payload using a Base64 string.
 voidsetStringPayload(string payload)

Stores a UTF-8 string as the payload.
 
Field detail

clientID

string clientID
The client identifier from the transport.

time

float time
The timestamp when the message was received from the device.

This field is ignored when sending a message to a device.

topic

string topic
The topic or destination identifier.

transportID

string transportID
The transport identifier (e.g., "mqtt").

transportProperties

dictionary<stringanytransportProperties
Transport-specific properties as key-value pairs.
Action detail

encodeJSONPayload

void encodeJSONPayload(any object)
Converts an object to a JSON string and stores it as the payload.
Parameters:
object - The object to serialize to JSON and store.
Throws:
Exception if JSON serialization fails.

getBinaryBase64Payload

string getBinaryBase64Payload()
Returns the payload encoded as a Base64 string.
Returns:
The payload encoded as a Base64 string.

getStringPayload

string getStringPayload()
Decodes the payload as a UTF-8 string.
Returns:
The UTF-8 decoded string from the payload.
Throws:
Exception if the content is not a valid UTF-8 string.

parseJSONPayload

any parseJSONPayload()
Decodes the payload as a UTF-8 string, then parses that string as JSON.
Returns:
The parsed JSON object.
Throws:
Exception if the payload is not valid UTF-8 or not valid JSON.

setBinaryBase64Payload

void setBinaryBase64Payload(string base64)
Sets the payload using a Base64 string.
Parameters:
base64 - The Base64-encoded string to store.

setStringPayload

void setStringPayload(string payload)
Stores a UTF-8 string as the payload.
Parameters:
payload - The UTF-8 string to store.