org.activemq.message
Class ActiveMQObjectMessage

java.lang.Object
  extended byorg.activemq.message.AbstractPacket
      extended byorg.activemq.message.ActiveMQMessage
          extended byorg.activemq.message.ActiveMQObjectMessage
All Implemented Interfaces:
BodyPacket, Comparable, MemoryManageable, Message, ObjectMessage, Packet

public class ActiveMQObjectMessage
extends ActiveMQMessage
implements ObjectMessage

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 Summary
 
Fields inherited from class org.activemq.message.ActiveMQMessage
BROKER_NAME_INDEX, CACHED_DESTINATION_INDEX, CACHED_VALUES_INDEX, CID_INDEX, CLUSTER_NAME_INDEX, CORRELATION_INDEX, DISPATCHED_FROM_DLQ_INDEX, EXPIRATION_INDEX, EXTERNAL_MESSAGE_ID_INDEX, LONG_SEQUENCE_INDEX, MESSAGE_PART_INDEX, PAYLOAD_INDEX, PROPERTIES_INDEX, readOnlyMessage, REDELIVERED_INDEX, REPLY_TO_INDEX, TIMESTAMP_INDEX, TRANSACTION_ID_INDEX, TYPE_INDEX, XA_TRANS_INDEX
 
Fields inherited from class org.activemq.message.AbstractPacket
bitArray, BROKERS_VISITED_INDEX, cachedHashCode, RECEIPT_REQUIRED_INDEX
 
Fields inherited from interface javax.jms.Message
DEFAULT_DELIVERY_MODE, DEFAULT_PRIORITY, DEFAULT_TIME_TO_LIVE
 
Fields inherited from interface org.activemq.message.Packet
ACTIVEMQ_BROKER_INFO, ACTIVEMQ_BYTES_MESSAGE, ACTIVEMQ_CONNECTION_INFO, ACTIVEMQ_MAP_MESSAGE, ACTIVEMQ_MESSAGE, ACTIVEMQ_MSG_ACK, ACTIVEMQ_OBJECT_MESSAGE, ACTIVEMQ_STREAM_MESSAGE, ACTIVEMQ_TEXT_MESSAGE, BROKER_ADMIN_COMMAND, CACHED_VALUE_COMMAND, CAPACITY_INFO, CAPACITY_INFO_REQUEST, CLEANUP_CONNECTION_INFO, CONSUMER_INFO, DURABLE_UNSUBSCRIBE, INT_RESPONSE_RECEIPT_INFO, KEEP_ALIVE, NOT_SET, PRODUCER_INFO, RECEIPT_INFO, RESPONSE_RECEIPT_INFO, SESSION_INFO, TRANSACTION_INFO, WIRE_FORMAT_INFO, XA_TRANSACTION_INFO
 
Constructor Summary
ActiveMQObjectMessage()
           
 
Method Summary
 void clearBody()
          Clears out the message body.
protected  JMSException createFailedToBuildBodyException(IOException ioe)
           
 ActiveMQMessage deepCopy()
           
 Serializable getObject()
          Gets the serializable object containing this message's data.
 int getPacketType()
          Return the type of Packet
 void prepareMessageBody()
          Prepare a message body for delivery
 void readBody(DataInput dataIn)
          Used to help build the body from an input stream
 void setObject(Serializable newObject)
          Sets the serializable object containing this message's data.
 void setObjectPayload(Object newObject)
           
 ActiveMQMessage shallowCopy()
           
 String toString()
           
 void writeBody(DataOutput dataOut)
          Used serialize the message body to an output stream
 
Methods inherited from class org.activemq.message.ActiveMQMessage
acknowledge, buildBodyFromBytes, clearProperties, compareTo, compareTo, convertBodyToBytes, equals, getBodyAsBytes, getBodyAsBytes, getBooleanProperty, getByteProperty, getConsumerIdentifer, getConsumerNos, getConsumerNosAsString, getDeliveryCount, getDoubleProperty, getEntryBrokerName, getEntryClusterName, getFloatProperty, getIntProperty, getJMSActiveMQDestination, getJMSClientID, getJMSCorrelationID, getJMSCorrelationIDAsBytes, getJMSDeliveryMode, getJMSDestination, getJMSExpiration, getJMSMessageID, getJMSMessageIdentity, getJMSPriority, getJMSRedelivered, getJMSReplyTo, getJMSTimestamp, getJMSType, getLongProperty, getMemoryId, getMessageAcknowledge, getMesssageHandle, getNumberOfParts, getObjectProperty, getParentMessageID, getPartNumber, getPriority, getProducerKey, getProperties, getPropertyNames, getSequenceNumber, getShortProperty, getStringProperty, getTransactionId, getTransactionIDString, hashCode, incrementDeliveryCount, incrementRedeliveryCount, initializeOther, isAdvisory, isBodyConvertedToBytes, isConsumerTarget, isDispatchedFromDLQ, isEntryBroker, isEntryCluster, isExpired, isExpired, isExternalMessageId, isJMSMessage, isLastMessagePart, isMessageConsumed, isMessagePart, isPartOfTransaction, isPersistent, isTemporary, isTransientConsumed, isXaTransacted, propertyExists, readMapProperties, resetMessagePart, setBodyAsBytes, setBodyAsBytes, setBooleanProperty, setByteProperty, setConsumerIdentifer, setConsumerNos, setConsumerNosAsString, setDeliveryCount, setDispatchedFromDLQ, setDoubleProperty, setEntryBrokerName, setEntryClusterName, setExternalMessageId, setFloatProperty, setIntProperty, setJMSClientID, setJMSCorrelationID, setJMSCorrelationIDAsBytes, setJMSDeliveryMode, setJMSDestination, setJMSExpiration, setJMSMessageID, setJMSMessageIdentity, setJMSPriority, setJMSRedelivered, setJMSReplyTo, setJMSTimestamp, setJMSType, setLongProperty, setMessageAcknowledge, setMessageConsumed, setMessagePart, setMesssageHandle, setNumberOfParts, setObjectProperty, setParentMessageID, setPartNumber, setProducerKey, setProperties, setReadOnly, setSequenceNumber, setShortProperty, setStringProperty, setTransactionId, setTransactionIDString, setTransientConsumed, toString, writeMapProperties
 
Methods inherited from class org.activemq.message.AbstractPacket
addBrokerVisited, clearBrokersVisited, decrementMemoryReferenceCount, equals, getBitArray, getBrokersVisited, getBrokersVisitedAsString, getId, getMemoryUsage, getMemoryUsageReferenceCount, getPacketTypeAsString, hasVisited, incrementMemoryReferenceCount, initializeOther, isReceipt, isReceiptRequired, setBitArray, setBrokersVisitedAsString, setId, setMemoryUsage, setReceiptRequired
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface javax.jms.Message
acknowledge, 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
 
Methods inherited from interface org.activemq.io.util.MemoryManageable
decrementMemoryReferenceCount, getMemoryUsage, getMemoryUsageReferenceCount, incrementMemoryReferenceCount
 

Constructor Detail

ActiveMQObjectMessage

public ActiveMQObjectMessage()
Method Detail

getPacketType

public int getPacketType()
Return the type of Packet

Specified by:
getPacketType in interface Packet
Overrides:
getPacketType in class ActiveMQMessage
Returns:
integer representation of the type of Packet

shallowCopy

public ActiveMQMessage shallowCopy()
                            throws JMSException
Overrides:
shallowCopy in class ActiveMQMessage
Returns:
Returns a shallow copy of the message instance
Throws:
JMSException

deepCopy

public ActiveMQMessage deepCopy()
                         throws JMSException
Overrides:
deepCopy in class ActiveMQMessage
Returns:
Returns a deep copy of the message - note the header fields are only shallow copied
Throws:
JMSException

clearBody

public void clearBody()
               throws 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 Message
Overrides:
clearBody in class ActiveMQMessage
Throws:
JMSException - if the JMS provider fails to clear the message body due to some internal error.

setObject

public void setObject(Serializable newObject)
               throws 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 ObjectMessage
Parameters:
newObject - the message's data
Throws:
JMSException - if the JMS 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.

setObjectPayload

public void setObjectPayload(Object newObject)

getObject

public Serializable getObject()
                       throws JMSException
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

prepareMessageBody

public void prepareMessageBody()
                        throws JMSException
Prepare a message body for delivery

Overrides:
prepareMessageBody in class ActiveMQMessage
Throws:
JMSException

writeBody

public void writeBody(DataOutput dataOut)
               throws IOException
Used serialize the message body to an output stream

Specified by:
writeBody in interface BodyPacket
Overrides:
writeBody in class ActiveMQMessage
Parameters:
dataOut -
Throws:
IOException

readBody

public void readBody(DataInput dataIn)
              throws IOException
Used to help build the body from an input stream

Specified by:
readBody in interface BodyPacket
Overrides:
readBody in class ActiveMQMessage
Parameters:
dataIn -
Throws:
IOException

toString

public String toString()
Overrides:
toString in class ActiveMQMessage
Returns:
pretty print of this Message

createFailedToBuildBodyException

protected JMSException createFailedToBuildBodyException(IOException ioe)


Copyright © 2004-2007 Protique, Ltd.. All Rights Reserved.