Class SQSObjectMessage

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

    public class SQSObjectMessage
    extends SQSMessage
    implements javax.jms.ObjectMessage
    An ObjectMessage object is used to send a message that contains a Java serializable object.

    It inherits from the Message interface and adds a body containing a single reference to an object. Only Serializable Java objects can be used.

    When a client receives an ObjectMessage, 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

      • SQSObjectMessage

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

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

        public SQSObjectMessage​(Serializable payload)
                         throws javax.jms.JMSException
        Create new ObjectMessage with payload to send.
        Throws:
        javax.jms.JMSException
    • Method Detail

      • setObject

        public void setObject​(Serializable payload)
                       throws javax.jms.JMSException
        Sets the Serializable containing this message's body
        Specified by:
        setObject in interface javax.jms.ObjectMessage
        Parameters:
        payload - The Serializable containing the message's body
        Throws:
        MessageNotWriteableException - If the message is in read-only mode.
        MessageFormatException - If object serialization fails.
        javax.jms.JMSException
      • getObject

        public Serializable getObject()
                               throws javax.jms.JMSException
        Gets the Serializable containing this message's body
        Specified by:
        getObject in interface javax.jms.ObjectMessage
        Throws:
        MessageFormatException - If object deserialization fails.
        javax.jms.JMSException
      • clearBody

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

        protected static Serializable deserialize​(String serialized)
                                           throws javax.jms.JMSException
        Deserialize the String into Serializable object.
        Throws:
        javax.jms.JMSException
      • serialize

        protected static String serialize​(Serializable serializable)
                                   throws javax.jms.JMSException
        Serialize the Serializable object to String.
        Throws:
        javax.jms.JMSException
      • getMessageBody

        public String getMessageBody()