javax.jms
Interface ObjectMessage
- All Superinterfaces:
- Message
- public interface ObjectMessage
- extends Message
An ObjectMessage is used to send a message that contains a serializable
Java object. It inherits from Message
and adds a body
containing a single Java reference. Only Serializable
Java
objects can be used.
If a collection of Java objects must be sent, one of the collection
classes provided in 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
Methods inherited from interface javax.jms.Message |
acknowledge, clearBody, clearProperties, getBooleanProperty, getByteProperty, getDoubleProperty, getFloatProperty, getIntProperty, getJMSCorrelationID, getJMSCorrelationIDAsBytes, getJMSDeliveryMode, getJMSDestination, getJMSExpiration, getJMSMessageID, getJMSPriority, getJMSRedelivered, getJMSReplyTo, getJMSTimestamp, getJMSType, getLongProperty, getObjectProperty, getPropertyNames, getShortProperty, getStringProperty, propertyExists, setBooleanProperty, setByteProperty, setDoubleProperty, setFloatProperty, setIntProperty, setJMSCorrelationID, setJMSCorrelationIDAsBytes, setJMSDeliveryMode, setJMSDestination, setJMSExpiration, setJMSMessageID, setJMSPriority, setJMSRedelivered, setJMSReplyTo, setJMSTimestamp, setJMSType, setLongProperty, setObjectProperty, setShortProperty, setStringProperty |
setObject
public void setObject(Serializable object)
throws JMSException
- Set 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
affect on the ObjectMessage
body.
- Parameters:
object
- the message's data- Throws:
JMSException
- if JMS fails to set object due to
some internal JMS error.MessageFormatException
- if object serialization failsMessageNotWriteableException
- if message in read-only mode.
getObject
public Serializable getObject()
throws JMSException
- Get the serializable object containing this message's data. The
default value is null.
- Returns:
- the serializable object containing this message's data
- Throws:
JMSException
- if JMS fails to get object due to
some internal JMS error.MessageFormatException
- if object deserialization fails