Class ActiveMQObjectMessage

  • All Implemented Interfaces:
    javax.jms.Message, javax.jms.ObjectMessage, MessageReference, Command, DataStructure, MarshallAware, TransientInitializer, Message, ScheduledMessage

    public class ActiveMQObjectMessage
    extends ActiveMQMessage
    implements javax.jms.ObjectMessage, TransientInitializer
    An ObjectMessage object is used to send a message that contains a serializable object in the Java programming language ("Java 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.

    If a collection of Java objects must be sent, one of the Collection classes provided since JDK 1.2 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.

    See Also:
    Session.createObjectMessage(), Session.createObjectMessage(Serializable), BytesMessage, MapMessage, Message, StreamMessage, TextMessage
    • Constructor Detail

      • ActiveMQObjectMessage

        public ActiveMQObjectMessage()
    • Method Detail

      • getJMSXMimeType

        public String getJMSXMimeType()
        Description copied from interface: Message
        Returns the MIME type of this mesage. This can be used in selectors to filter on the MIME types of the different JMS messages, or in the case of BlobMessage it allows you to create a selector on the MIME type of the BLOB body
        Specified by:
        getJMSXMimeType in interface Message
        Overrides:
        getJMSXMimeType in class ActiveMQMessage
      • clearBody

        public void clearBody()
                       throws javax.jms.JMSException
        Clears out the message body. Clearing a message's body does not clear its header values or property entries.

        If this message body was read-only, calling this method leaves the message body in the same state as an empty body in a newly created message.

        Specified by:
        clearBody in interface javax.jms.Message
        Overrides:
        clearBody in class ActiveMQMessage
        Throws:
        javax.jms.JMSException - if the JMS provider fails to clear the message body due to some internal error.
      • setObject

        public void setObject​(Serializable newObject)
                       throws javax.jms.JMSException
        Sets the serializable object containing this message's data. It is important to note that an ObjectMessage contains a snapshot of the object at the time setObject() is called; subsequent modifications of the object will have no effect on the ObjectMessage body.
        Specified by:
        setObject in interface javax.jms.ObjectMessage
        Parameters:
        newObject - the message's data
        Throws:
        javax.jms.JMSException - if the JMS provider fails to set the object due to some internal error.
        javax.jms.MessageFormatException - if object serialization fails.
        javax.jms.MessageNotWriteableException - if the message is in read-only mode.
      • getObject

        public Serializable getObject()
                               throws javax.jms.JMSException
        Gets the serializable object containing this message's data. The default value is null.
        Specified by:
        getObject in interface javax.jms.ObjectMessage
        Returns:
        the serializable object containing this message's data
        Throws:
        javax.jms.JMSException
      • clearUnMarshalledState

        public void clearUnMarshalledState()
                                    throws javax.jms.JMSException
        Overrides:
        clearUnMarshalledState in class Message
        Throws:
        javax.jms.JMSException
      • getTrustedPackages

        public List<String> getTrustedPackages()
      • setTrustedPackages

        public void setTrustedPackages​(List<String> trustedPackages)
      • isTrustAllPackages

        public boolean isTrustAllPackages()
      • setTrustAllPackages

        public void setTrustAllPackages​(boolean trustAllPackages)
      • isBodyAssignableTo

        public boolean isBodyAssignableTo​(Class c)
                                   throws javax.jms.JMSException
        Specified by:
        isBodyAssignableTo in interface javax.jms.Message
        Overrides:
        isBodyAssignableTo in class ActiveMQMessage
        Throws:
        javax.jms.JMSException
      • doGetBody

        protected <T> T doGetBody​(Class<T> asType)
                           throws javax.jms.JMSException
        Overrides:
        doGetBody in class ActiveMQMessage
        Throws:
        javax.jms.JMSException