Class ActiveMQObjectMessage

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

public class ActiveMQObjectMessage extends ActiveMQMessage implements jakarta.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
  • Field Details

  • Constructor Details

    • ActiveMQObjectMessage

      public ActiveMQObjectMessage()
  • Method Details

    • copy

      public Message copy()
      Overrides:
      copy in class ActiveMQMessage
    • storeContentAndClear

      public void storeContentAndClear()
      Overrides:
      storeContentAndClear in class ActiveMQMessage
    • storeContent

      public void storeContent()
      Overrides:
      storeContent in class ActiveMQMessage
    • isContentMarshalled

      public boolean isContentMarshalled()
      Overrides:
      isContentMarshalled in class ActiveMQMessage
    • getDataStructureType

      public byte getDataStructureType()
      Specified by:
      getDataStructureType in interface DataStructure
      Overrides:
      getDataStructureType in class ActiveMQMessage
      Returns:
      The type of the data structure
    • 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 jakarta.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 jakarta.jms.Message
      Overrides:
      clearBody in class ActiveMQMessage
      Throws:
      jakarta.jms.JMSException - if the JMS provider fails to clear the message body due to some internal error.
    • setObject

      public void setObject(Serializable newObject) throws jakarta.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 jakarta.jms.ObjectMessage
      Parameters:
      newObject - the message's data
      Throws:
      jakarta.jms.JMSException - if the JMS provider fails to set the object due to some internal error.
      jakarta.jms.MessageFormatException - if object serialization fails.
      jakarta.jms.MessageNotWriteableException - if the message is in read-only mode.
    • getObject

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

      public void beforeMarshall(WireFormat wireFormat) throws IOException
      Specified by:
      beforeMarshall in interface MarshallAware
      Overrides:
      beforeMarshall in class Message
      Throws:
      IOException
    • clearUnMarshalledState

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

      public void onMessageRolledBack()
      Overrides:
      onMessageRolledBack in class Message
    • compress

      public void compress() throws IOException
      Overrides:
      compress in class Message
      Throws:
      IOException
    • toString

      public String toString()
      Overrides:
      toString in class Message
    • getTrustedPackages

      public List<String> getTrustedPackages()
    • setTrustedPackages

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

      public boolean isTrustAllPackages()
    • setTrustAllPackages

      public void setTrustAllPackages(boolean trustAllPackages)
    • initTransients

      public void initTransients()
      Specified by:
      initTransients in interface TransientInitializer
    • isBodyAssignableTo

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

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