Class TextMessage

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

    public final class TextMessage
    extends Message
    implements jakarta.jms.TextMessage
    Implements the jakarta.jms.TextMessage interface.
    • Constructor Detail

      • TextMessage

        TextMessage()
        Instantiates a bright new TextMessage.
      • TextMessage

        TextMessage​(Session session,
                    Message momMsg)
        Instantiates a TextMessage wrapping a consumed MOM message containing a text.
        Parameters:
        session - The consuming session.
        momMsg - The MOM message to wrap.
    • Method Detail

      • setText

        public void setText​(String text)
                     throws jakarta.jms.MessageNotWriteableException,
                            jakarta.jms.MessageFormatException
        API method. Sets a String as the body of the message.
        Specified by:
        setText in interface jakarta.jms.TextMessage
        Parameters:
        text - the String containing the message's data.
        Throws:
        jakarta.jms.MessageNotWriteableException - When trying to set the text if the message body is read-only.
        jakarta.jms.MessageFormatException - If the text serialization fails.
      • getText

        public String getText()
                       throws jakarta.jms.JMSException
        API method. Returns the text body of the message, null if none.
        Specified by:
        getText in interface jakarta.jms.TextMessage
        Returns:
        the String containing this message's data.
        Throws:
        jakarta.jms.JMSException - In case of a problem when getting the body.
      • getEffectiveBody

        protected <T> T getEffectiveBody​(Class<T> c)
                                  throws jakarta.jms.JMSException
        Description copied from class: Message
        Get message body
        Overrides:
        getEffectiveBody in class Message
        Parameters:
        c - The type to which the message body will be assigned.
        Returns:
        message body
        Throws:
        jakarta.jms.JMSException - if the JMS provider fails to return a value due to some internal error.