Class AWSIotMessage

java.lang.Object
com.amazonaws.services.iot.client.AWSIotMessage
All Implemented Interfaces:
AwsIotMessageCallback
Direct Known Subclasses:
AwsIotCompletion, AwsIotDeviceReportMessage, AwsIotDeviceSyncMessage, AWSIotTopic

public class AWSIotMessage extends Object implements AwsIotMessageCallback
A common data structure that is used in a lot of non-blocking APIs in this library.

It provides common data elements, such as topic, qos, and payload, used by the APIs.

It also contains callback functions that can be overridden to provide customized handlers. The callback functions are invoked when a non-blocking API call has completed successfully, unsuccessfully, or timed out. Applications wish to have customized callback functions must extend this class or its child classes, such as AWSIotTopic.

  • Field Details

    • topic

      protected String topic
      The topic the message is received from or published to.
    • qos

      protected AWSIotQos qos
      The MQTT QoS level for the message.
    • payload

      protected byte[] payload
      The payload of the message.
    • errorCode

      protected AWSIotDeviceErrorCode errorCode
      Error code for shadow methods. It's only applicable to messages returned by those shadow method APIs.
    • errorMessage

      protected String errorMessage
      Error message for shadow methods. It's only applicable to messages returned by those shadow method APIs.
  • Constructor Details

    • AWSIotMessage

      public AWSIotMessage(String topic, AWSIotQos qos)
      Instantiates a new message object.
      Parameters:
      topic - the topic of the message
      qos - the QoS level of the message
    • AWSIotMessage

      public AWSIotMessage(String topic, AWSIotQos qos, byte[] payload)
      Instantiates a new message object.
      Parameters:
      topic - the topic of the message
      qos - the QoS level of the message
      payload - the payload of the message
    • AWSIotMessage

      public AWSIotMessage(String topic, AWSIotQos qos, String payload)
      Instantiates a new message object.
      Parameters:
      topic - the topic of the message
      qos - the QoS level of the message
      payload - the payload of the message
  • Method Details

    • getPayload

      public byte[] getPayload()
      Gets the byte array payload.
      Returns:
      the byte array payload
    • setPayload

      public void setPayload(byte[] payload)
      Sets the byte array payload.
      Parameters:
      payload - the new byte array payload
    • getStringPayload

      public String getStringPayload()
      Gets the string payload.
      Returns:
      the string payload
    • setStringPayload

      public void setStringPayload(String payload)
      Sets the string payload.
      Parameters:
      payload - the new string payload
    • onSuccess

      public void onSuccess()
      Callback function to be invoked a non-block API has completed successfully.
      Specified by:
      onSuccess in interface AwsIotMessageCallback
    • onFailure

      public void onFailure()
      Callback function to be invoked a non-block API has completed unsuccessfully.
      Specified by:
      onFailure in interface AwsIotMessageCallback
    • onTimeout

      public void onTimeout()
      Callback function to be invoked a non-block API has timed out.
      Specified by:
      onTimeout in interface AwsIotMessageCallback
    • getTopic

      public String getTopic()
      The topic the message is received from or published to.
      Returns:
      the current topic of the message
    • setTopic

      public void setTopic(String topic)
      The topic the message is received from or published to.
      Parameters:
      topic - the new topic of the message
    • getQos

      public AWSIotQos getQos()
      The MQTT QoS level for the message.
      Returns:
      the current QoS level
    • setQos

      public void setQos(AWSIotQos qos)
      The MQTT QoS level for the message.
      Parameters:
      qos - the new QoS level
    • getErrorCode

      public AWSIotDeviceErrorCode getErrorCode()
      Error code for shadow methods. It's only applicable to messages returned by those shadow method APIs.
      Returns:
      the current error code of the shadow method
    • setErrorCode

      public void setErrorCode(AWSIotDeviceErrorCode errorCode)
      Error code for shadow methods. It's only applicable to messages returned by those shadow method APIs.
      Parameters:
      errorCode - the new error code for the shadow method
    • getErrorMessage

      public String getErrorMessage()
      Error message for shadow methods. It's only applicable to messages returned by those shadow method APIs.
      Returns:
      the current error message of the shadow method
    • setErrorMessage

      public void setErrorMessage(String errorMessage)
      Error message for shadow methods. It's only applicable to messages returned by those shadow method APIs.
      Parameters:
      errorMessage - the new error message for the shadow method