Class SQSTextMessage

  • All Implemented Interfaces:
    javax.jms.Message, javax.jms.TextMessage

    public class SQSTextMessage
    extends SQSMessage
    implements javax.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 Detail

      • SQSTextMessage

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

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

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

      • setText

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

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

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