Class ActiveMQObjectMessage

java.lang.Object
org.apache.activemq.artemis.jms.client.ActiveMQMessage
org.apache.activemq.artemis.jms.client.ActiveMQObjectMessage
All Implemented Interfaces:
Message, ObjectMessage
Direct Known Subclasses:
ActiveMQObjectCompatibleMessage

public class ActiveMQObjectMessage extends ActiveMQMessage implements ObjectMessage
ActiveMQ Artemis implementation of a JMS ObjectMessage.

Don't used ObjectMessage if you want good performance!

Serialization is slooooow!

  • Field Details

  • Constructor Details

  • Method Details

    • getType

      public byte getType()
      Overrides:
      getType in class ActiveMQMessage
    • doBeforeSend

      public void doBeforeSend() throws Exception
      Overrides:
      doBeforeSend in class ActiveMQMessage
      Throws:
      Exception
    • doBeforeReceive

      public void doBeforeReceive() throws ActiveMQException
      Overrides:
      doBeforeReceive in class ActiveMQMessage
      Throws:
      ActiveMQException
    • setObject

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

      public Serializable getObject() throws JMSException
      Description copied from interface: ObjectMessage
      Gets the serializable object containing this message's data. The default value is null.
      Specified by:
      getObject in interface ObjectMessage
      Returns:
      the serializable object containing this message's data
      Throws:
      JMSException - if the Jakarta Messaging provider fails to get the object due to some internal error.
      MessageFormatException - if object deserialization fails.
    • clearBody

      public void clearBody() throws JMSException
      Description copied from interface: Message
      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 Message
      Overrides:
      clearBody in class ActiveMQMessage
      Throws:
      JMSException - if the Jakarta Messaging provider fails to clear the message body due to some internal error.
    • getBodyInternal

      protected <T> T getBodyInternal(Class<T> c) throws MessageFormatException
      Overrides:
      getBodyInternal in class ActiveMQMessage
      Throws:
      MessageFormatException
    • isBodyAssignableTo

      public boolean isBodyAssignableTo(Class c)
      Description copied from class: ActiveMQMessage
      From the specs:

      If the message is a Message (but not one of its subtypes) then this method will return true irrespective of the value of this parameter.

      Specified by:
      isBodyAssignableTo in interface Message
      Overrides:
      isBodyAssignableTo in class ActiveMQMessage
      Parameters:
      c - The specified type
      If the message is a TextMessage then this method will only return true if this parameter is set to String.class or another type to which a String is assignable.
      If the message is a ObjectMessage then this method will only return true if this parameter is set to java.io.Serializable.class or another class to which the body is assignable.
      If the message is a MapMessage then this method will only return true if this parameter is set to java.util.Map.class (or java.lang.Object.class).
      If the message is a BytesMessage then this this method will only return true if this parameter is set to byte[].class (or java.lang.Object.class).
      If the message is a TextMessage, ObjectMessage, MapMessage or BytesMessage and the message has no body, then the above does not apply and this method will return true irrespective of the value of this parameter.
      If the message is a Message (but not one of its subtypes) then this method will return true irrespective of the value of this parameter.
      Returns:
      whether the message body is capable of being assigned to the specified type