Class SQSTextMessage

java.lang.Object
com.amazon.sqs.javamessaging.message.SQSMessage
com.amazon.sqs.javamessaging.message.SQSTextMessage
All Implemented Interfaces:
jakarta.jms.Message, jakarta.jms.TextMessage

public class SQSTextMessage extends SQSMessage implements jakarta.jms.TextMessage
A TextMessage object is used to send a message body containing a java.lang.String. It inherits from the Message interface and adds a text message body. SQS does not accept empty or null message body

When a client receives a TextMessage, it is in read-only mode. If a client attempts to write to the message at this point, a MessageNotWriteableException is thrown. If clearBody is called, the message can now be both read from and written to.

  • Constructor Details

    • SQSTextMessage

      public SQSTextMessage(Acknowledger acknowledger, String queueUrl, software.amazon.awssdk.services.sqs.model.Message sqsMessage) throws jakarta.jms.JMSException
      Convert received SQSMessage into TextMessage.
      Throws:
      jakarta.jms.JMSException
    • SQSTextMessage

      public SQSTextMessage() throws jakarta.jms.JMSException
      Create new empty TextMessage to send.
      Throws:
      jakarta.jms.JMSException
    • SQSTextMessage

      public SQSTextMessage(String payload) throws jakarta.jms.JMSException
      Create new TextMessage with payload to send.
      Throws:
      jakarta.jms.JMSException
  • Method Details

    • setText

      public void setText(String string) throws jakarta.jms.JMSException
      Sets the text containing this message's body.
      Specified by:
      setText in interface jakarta.jms.TextMessage
      Parameters:
      string - The String containing the message's body
      Throws:
      jakarta.jms.MessageNotWriteableException - If the message is in read-only mode.
      jakarta.jms.JMSException
    • getText

      public String getText() throws jakarta.jms.JMSException
      Gets the text containing this message's body.
      Specified by:
      getText in interface jakarta.jms.TextMessage
      Returns:
      The String containing the message's body
      Throws:
      jakarta.jms.JMSException
    • clearBody

      public void clearBody() throws jakarta.jms.JMSException
      Sets the message body to write mode, and sets the text to null
      Specified by:
      clearBody in interface jakarta.jms.Message
      Overrides:
      clearBody in class SQSMessage
      Throws:
      jakarta.jms.JMSException - If directly called