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 Summary
Fields Modifier and Type Field Description static byteTYPE-
Fields inherited from class org.apache.activemq.artemis.jms.client.ActiveMQMessage
message, OLD_QUEUE_QUALIFIED_PREFIX, OLD_TEMP_QUEUE_QUALIFED_PREFIX, OLD_TEMP_TOPIC_QUALIFED_PREFIX, OLD_TOPIC_QUALIFIED_PREFIX, propertiesReadOnly, readOnly, replyTo
-
Fields inherited from interface jakarta.jms.Message
DEFAULT_DELIVERY_DELAY, DEFAULT_DELIVERY_MODE, DEFAULT_PRIORITY, DEFAULT_TIME_TO_LIVE
-
-
Constructor Summary
Constructors Modifier Constructor Description ActiveMQObjectMessage(ObjectMessage foreign, ClientSession session, ConnectionFactoryOptions options)A copy constructor for foreign JMS ObjectMessages.protectedActiveMQObjectMessage(ClientMessage message, ClientSession session, ConnectionFactoryOptions options)protectedActiveMQObjectMessage(ClientSession session, ConnectionFactoryOptions options)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclearBody()Clears out the message body.voiddoBeforeReceive()voiddoBeforeSend()protected <T> TgetBodyInternal(Class<T> c)SerializablegetObject()Gets the serializable object containing this message's data.bytegetType()booleanisBodyAssignableTo(Class c)Returns whether the message body is capable of being assigned to the specified type.voidsetObject(Serializable object)Sets the serializable object containing this message's data.-
Methods inherited from class org.apache.activemq.artemis.jms.client.ActiveMQMessage
acknowledge, checkBuffer, checkPrefix, checkPrefixStr, checkRead, checkWrite, clearProperties, coreCompositeTypeToJMSCompositeType, coreMaptoJMSMap, createMessage, createMessage, getBody, getBooleanProperty, getByteProperty, getCoreMessage, getDoubleProperty, getFloatProperty, getIntProperty, getJMSCorrelationID, getJMSCorrelationIDAsBytes, getJMSDeliveryMode, getJMSDeliveryTime, getJMSDestination, getJMSExpiration, getJMSMessageID, getJMSPriority, getJMSRedelivered, getJMSReplyTo, getJMSTimestamp, getJMSType, getLongProperty, getObjectProperty, getPropertyNames, getShortProperty, getStringProperty, hasNoBody, prefixOf, propertyExists, resetMessageID, saveToOutputStream, setBooleanProperty, setByteProperty, setClientAcknowledge, setDoubleProperty, setFloatProperty, setIndividualAcknowledge, setInputStream, setIntProperty, setJMSCorrelationID, setJMSCorrelationIDAsBytes, setJMSDeliveryMode, setJMSDeliveryTime, setJMSDestination, setJMSExpiration, setJMSMessageID, setJMSPriority, setJMSRedelivered, setJMSReplyTo, setJMSTimestamp, setJMSType, setLongProperty, setObjectProperty, setOutputStream, setShortProperty, setStringProperty, toString, waitCompletionOnStream
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface jakarta.jms.Message
acknowledge, clearProperties, getBody, getBooleanProperty, getByteProperty, getDoubleProperty, getFloatProperty, getIntProperty, getJMSCorrelationID, getJMSCorrelationIDAsBytes, getJMSDeliveryMode, getJMSDeliveryTime, getJMSDestination, getJMSExpiration, getJMSMessageID, getJMSPriority, getJMSRedelivered, getJMSReplyTo, getJMSTimestamp, getJMSType, getLongProperty, getObjectProperty, getPropertyNames, getShortProperty, getStringProperty, propertyExists, setBooleanProperty, setByteProperty, setDoubleProperty, setFloatProperty, setIntProperty, setJMSCorrelationID, setJMSCorrelationIDAsBytes, setJMSDeliveryMode, setJMSDeliveryTime, setJMSDestination, setJMSExpiration, setJMSMessageID, setJMSPriority, setJMSRedelivered, setJMSReplyTo, setJMSTimestamp, setJMSType, setLongProperty, setObjectProperty, setShortProperty, setStringProperty
-
-
-
-
Field Detail
-
TYPE
public static final byte TYPE
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ActiveMQObjectMessage
protected ActiveMQObjectMessage(ClientSession session, ConnectionFactoryOptions options)
-
ActiveMQObjectMessage
protected ActiveMQObjectMessage(ClientMessage message, ClientSession session, ConnectionFactoryOptions options)
-
ActiveMQObjectMessage
public ActiveMQObjectMessage(ObjectMessage foreign, ClientSession session, ConnectionFactoryOptions options) throws JMSException
A copy constructor for foreign JMS ObjectMessages.- Throws:
JMSException
-
-
Method Detail
-
getType
public byte getType()
- Overrides:
getTypein classActiveMQMessage
-
doBeforeSend
public void doBeforeSend() throws Exception- Overrides:
doBeforeSendin classActiveMQMessage- Throws:
Exception
-
doBeforeReceive
public void doBeforeReceive() throws ActiveMQException- Overrides:
doBeforeReceivein classActiveMQMessage- Throws:
ActiveMQException
-
setObject
public void setObject(Serializable object) throws JMSException
Description copied from interface:ObjectMessageSets the serializable object containing this message's data. It is important to note that anObjectMessagecontains a snapshot of the object at the timesetObject()is called; subsequent modifications of the object will have no effect on theObjectMessagebody.- Specified by:
setObjectin interfaceObjectMessage- 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:ObjectMessageGets the serializable object containing this message's data. The default value is null.- Specified by:
getObjectin interfaceObjectMessage- 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 JMSExceptionDescription copied from interface:MessageClears 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:
clearBodyin interfaceMessage- Overrides:
clearBodyin classActiveMQMessage- 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:
getBodyInternalin classActiveMQMessage- Throws:
MessageFormatException
-
isBodyAssignableTo
public boolean isBodyAssignableTo(Class c)
Description copied from interface:MessageReturns whether the message body is capable of being assigned to the specified type. If this method returns true then a subsequent call to the methodgetBodyon the same message with the same type argument would not throw a MessageFormatException.If the message is a
StreamMessagethen false is always returned. If the message is aObjectMessageand object deserialization fails then false is returned. If the message has no body then any type may be specified and true is returned.- Specified by:
isBodyAssignableToin interfaceMessage- Overrides:
isBodyAssignableToin classActiveMQMessage- Parameters:
c- The specified type
If the message is aTextMessagethen this method will only return true if this parameter is set toString.classor another type to which aStringis assignable.
If the message is aObjectMessagethen this method will only return true if this parameter is set tojava.io.Serializable.classor another class to which the body is assignable.
If the message is aMapMessagethen this method will only return true if this parameter is set tojava.util.Map.class(orjava.lang.Object.class).
If the message is aBytesMessagethen this this method will only return true if this parameter is set tobyte[].class(orjava.lang.Object.class).
If the message is aTextMessage,ObjectMessage,MapMessageorBytesMessageand 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 aMessage(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
-
-