Class Message
- java.lang.Object
-
- org.objectweb.joram.client.jms.Message
-
- All Implemented Interfaces:
Message
- Direct Known Subclasses:
AdminMessage,BytesMessage,MapMessage,ObjectMessage,StreamMessage,TextMessage
public class Message extends Object implements Message
Implements thejavax.jms.Messageinterface.A Joram message encapsulates a proprietary message which is used for effective MOM transport facility. It defines the message header and properties, and the acknowledge method used for all messages.
JMS messages are composed of the following parts:
- Header - All messages support the same set of header fields. Header fields contain values used by both clients and providers to identify and route messages.
- Properties - Each message contains a built-in facility for supporting application-defined property values. Properties provide an efficient mechanism for supporting message filtering.
- Body - The JMS API defines several types of message body, which cover the majority of messaging styles currently in use.
- Stream - A StreamMessage object's message body contains a stream of primitive values.
- Map - A MapMessage object's message body contains a set of name-value pairs, where names are String objects, and values are Java primitives.
- Text - A TextMessage object's message body contains a java.lang.String object.
- Object - An ObjectMessage object's message body contains a Serializable Java object.
- Bytes - A BytesMessage object's message body contains a stream of uninterpreted bytes.
-
-
Field Summary
Fields Modifier and Type Field Description private static booleanfirstprotected DestinationjmsDestThe JMSDestination field.static org.objectweb.util.monolog.api.Loggerloggerprotected org.objectweb.joram.shared.messages.MessagemomMsgbooleanpropertiesROtrueif the properties are read-only.protected booleanRObodytrueif the message body is read-only.protected SessionsessionIf the message is actually consumed, the session that consumes it,nullotherwise.private static booleanstrictVerificationErrorprivate static booleanstrictVerificationWarn-
Fields inherited from interface javax.jms.Message
DEFAULT_DELIVERY_DELAY, DEFAULT_DELIVERY_MODE, DEFAULT_PRIORITY, DEFAULT_TIME_TO_LIVE
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidacknowledge()API method.private voidcheckIdentifier(String identifier)voidclearBody()API method.voidclearProperties()API method.static MessageconvertJMSMessage(Message jmsMsg)Converts a non-Joram JMS message into a Joram message.private ObjectdoGetProperty(String name)Method actually getting a property.private voiddoSetProperty(String name, Object value)Method actually setting a new property.StringdumpBody()Returns an hex + ascii dump of the message body.AppendabledumpBody(Appendable strbuf)Appends an hex + ascii dump of the message body to the buffer.<T> TgetBody(Class<T> c)Returns the message body as an object of the specified type.booleangetBooleanProperty(String name)API method.bytegetByteProperty(String name)API method.intgetCompressedMinSize()Returns the minimum size beyond which this message's body is compressed.intgetCompressionLevel()Returns the compression level (0..9) used when this message body is compressed.doublegetDoubleProperty(String name)API method.protected <T> TgetEffectiveBody(Class<T> c)Get message bodyfloatgetFloatProperty(String name)API method.intgetIntProperty(String name)API method.StringgetJMSCorrelationID()API method.byte[]getJMSCorrelationIDAsBytes()API method.intgetJMSDeliveryMode()API method.longgetJMSDeliveryTime()API 2.0 Gets the message delivery time value.DestinationgetJMSDestination()Returns the message destination.longgetJMSExpiration()API method.StringgetJMSMessageID()API method.intgetJMSPriority()API method.booleangetJMSRedelivered()API method.DestinationgetJMSReplyTo()API method.longgetJMSTimestamp()API method.StringgetJMSType()API method.longgetLongProperty(String name)API method.org.objectweb.joram.shared.messages.MessagegetMomMsg()ObjectgetObjectProperty(String name)API method.voidgetProperties(Map h)Copies all of the mappings from the properties of this message to the specified map.EnumerationgetPropertyNames()API method.byte[]getRawBody()Returns the message body in raw format.shortgetShortProperty(String name)API method.StringgetStringProperty(String name)API method.private static voidinitStrictVerification()booleanisBodyAssignableTo(Class c)API 2.0 methodbooleanisCompressed()protected voidprepare()Method preparing the message for sending; resets header values, and serializes the body (done in subclasses).static voidprepareJMSMessage(Message msg)Prepare a JMS message for sending.booleanpropertyExists(String name)API method.voidresetPropertiesRO()Resets the read-only flag, in order to allow the modification of message properties.voidsetBooleanProperty(String name, boolean value)API method.voidsetByteProperty(String name, byte value)API method.voidsetCompressedMinSize(int compressedMinSize)Sets the minimum size beyond which this message's body is compressed.voidsetCompressionLevel(int compressionLevel)Sets the compression level (0..9) used when this message body is compressed.voidsetDoubleProperty(String name, double value)API method.voidsetFloatProperty(String name, float value)API method.voidsetIntProperty(String name, int value)API method.voidsetJMSCorrelationID(String correlationID)API method.voidsetJMSCorrelationIDAsBytes(byte[] correlationID)API method.voidsetJMSDeliveryMode(int deliveryMode)API method.voidsetJMSDeliveryTime(long deliveryTime)API 2.0 Sets the message delivery time value.voidsetJMSDestination(Destination dest)API method.voidsetJMSExpiration(long expiration)API method.voidsetJMSMessageID(String id)API method.voidsetJMSPriority(int priority)API method.voidsetJMSRedelivered(boolean redelivered)API method.voidsetJMSReplyTo(Destination replyTo)API method.voidsetJMSTimestamp(long timestamp)API method.voidsetJMSType(String type)API method.voidsetLongProperty(String name, long value)API method.voidsetObjectProperty(String name, Object value)API method.private voidsetReadOnly()set message read-onlyvoidsetShortProperty(String name, short value)API method.voidsetStringProperty(String name, String value)API method.private static booleanstrictVerificationError()private static booleanstrictVerificationWarn()StringtoString()voidtoString(StringBuffer strbuf)static MessagewrapMomMessage(Session session, org.objectweb.joram.shared.messages.Message momMsg)Builds a Joram/JMS message from a Joram shared message.
-
-
-
Field Detail
-
logger
public static org.objectweb.util.monolog.api.Logger logger
-
momMsg
protected org.objectweb.joram.shared.messages.Message momMsg
-
session
protected transient Session session
If the message is actually consumed, the session that consumes it,nullotherwise.
-
jmsDest
protected transient Destination jmsDest
The JMSDestination field. This field is only use with non Joram destination.
-
RObody
protected boolean RObody
trueif the message body is read-only.
-
propertiesRO
public boolean propertiesRO
trueif the properties are read-only.
-
first
private static boolean first
-
strictVerificationError
private static boolean strictVerificationError
-
strictVerificationWarn
private static boolean strictVerificationWarn
-
-
Constructor Detail
-
Message
protected Message()
Constructs a bright newMessage.
-
Message
protected Message(Session session, org.objectweb.joram.shared.messages.Message momMsg)
Instantiates aMessagewrapping a consumed MOM simple message.- Parameters:
session- The consuming session.momMsg- The MOM message to wrap.
-
-
Method Detail
-
setCompressedMinSize
public void setCompressedMinSize(int compressedMinSize)
Sets the minimum size beyond which this message's body is compressed.- Parameters:
compressedMinSize- the minimum size beyond which this message's body is compressed
-
getCompressedMinSize
public final int getCompressedMinSize()
Returns the minimum size beyond which this message's body is compressed. This attribute is inherited from Session at message creation, the default value is 0 (no compression).- Returns:
- the minimum size beyond which this message's body is compressed.
-
isCompressed
public final boolean isCompressed()
- Returns:
- true if compressed
-
setCompressionLevel
public final void setCompressionLevel(int compressionLevel)
Sets the compression level (0..9) used when this message body is compressed. This attribute is inherited from Session at message creation, the default value is 1 (Deflater.BEST_SPEED).- Parameters:
compressionLevel- the compression level (0-9)
-
getCompressionLevel
public final int getCompressionLevel()
Returns the compression level (0..9) used when this message body is compressed. This attribute is inherited from Session at message creation, the default value is 1 (Deflater.BEST_SPEED).- Returns:
- the compression level
-
wrapMomMessage
public static Message wrapMomMessage(Session session, org.objectweb.joram.shared.messages.Message momMsg) throws JMSException
Builds a Joram/JMS message from a Joram shared message.- Parameters:
session-momMsg-- Returns:
- Throws:
JMSException
-
acknowledge
public void acknowledge() throws JMSExceptionAPI method. Acknowledges all previously consumed messages of the session of this consumed message.All consumed JMS messages support the acknowledge method for use when a client has specified that its JMS session's consumed messages are to be explicitly acknowledged. By invoking acknowledge on a consumed message, a client implicitly acknowledges all messages consumed by the session that the message was delivered to.
Calls to acknowledge are ignored for both transacted sessions and sessions specified to use implicit acknowledgement modes.
Messages that have been received but not acknowledged may be redelivered.
- Specified by:
acknowledgein interfaceMessage- Throws:
IllegalStateException- If the session is closed.JMSException- If the acknowledgement fails for any other reason.
-
clearBody
public void clearBody() throws JMSExceptionAPI method. Clears the message's body.Calling this method leaves the message body in the same state as an empty body in a newly created message.
- Specified by:
clearBodyin interfaceMessage- Throws:
JMSException- Actually never thrown.
-
setReadOnly
private void setReadOnly()
set message read-only
-
getJMSMessageID
public final String getJMSMessageID() throws JMSException
API method. Returns the unique message identifier.The JMSMessageID header field contains a value that uniquely identifies each message sent by Joram. When a message is sent, JMSMessageID is ignored, when the send or publish method returns, it contains an unique identifier assigned by Joram.
All JMSMessageID values starts with the prefix 'ID:'.
- Specified by:
getJMSMessageIDin interfaceMessage- Returns:
- the unique message identifier.
- Throws:
JMSException- Actually never thrown.
-
setJMSMessageID
public final void setJMSMessageID(String id) throws JMSException
API method. Sets the message identifier.This field is set when a message is sent, this method can only be used to change the value for a message that has been received.
- Specified by:
setJMSMessageIDin interfaceMessage- Parameters:
id- the identifier for this message.- Throws:
JMSException- Actually never thrown.
-
getJMSPriority
public final int getJMSPriority() throws JMSExceptionAPI method. Returns the message priority.The JMS API defines ten levels of priority value, with 0 as the lowest priority and 9 as the highest. In addition, clients should consider priorities 0-4 as gradations of normal priority and priorities 5-9 as gradations of expedited priority.
Default prioprity is defined by Message.DEFAULT_PRIORITY.
- Specified by:
getJMSPriorityin interfaceMessage- Returns:
- the message priority.
- Throws:
JMSException- Actually never thrown.
-
setJMSPriority
public final void setJMSPriority(int priority) throws JMSExceptionAPI method. Sets the priority level for this message.This field is set when a message is sent, this method can be used to change the value for a message that has been received.
- Specified by:
setJMSPriorityin interfaceMessage- Parameters:
priority- the priority of this message.- Throws:
JMSException- If the priority value is incorrect.
-
getJMSDestination
public final Destination getJMSDestination() throws JMSException
Returns the message destination. This field is set bySession.send(), it can be overloaded for received messages. API method. Returns the message destination. This field is set by the provider at sending, it contains the destination to which the message is being sent.When a message is sent, this field is ignored. After completion of the send or publish method, the field holds the destination specified by the method.
When a message is received, its JMSDestination value must be equivalent to the value assigned when it was sent. This field can be overloaded for received messages.
- Specified by:
getJMSDestinationin interfaceMessage- Returns:
- the destination of this message.
- Throws:
JMSException- Actually never thrown.
-
setJMSDestination
public final void setJMSDestination(Destination dest) throws JMSException
API method. Set the message destination.This field is set when message is sent, this method can only be used to change the value for a message that has been received.
- Specified by:
setJMSDestinationin interfaceMessage- Parameters:
dest- the destination for this message.- Throws:
JMSException- If the destination id not a Joram's one.
-
getJMSExpiration
public final long getJMSExpiration() throws JMSExceptionAPI method. Returns the message expiration time.When a message is sent, the JMSExpiration header field is ignored. After completion of the send or publish method, it holds the expiration time of the message. This is the sum of the time-to-live value specified by the client and the GMT at the time of the send or publish.
If the time-to-live is specified as zero, JMSExpiration is set to zero to indicate that the message does not expire.
When a message's expiration time is reached, it is either discarded or forwarded to a DeadMessageQueue.
- Specified by:
getJMSExpirationin interfaceMessage- Returns:
- the time the message expires, which is the sum of the time-to-live value specified by the client and the GMT at the time of the send.
- Throws:
JMSException- Actually never thrown.
-
setJMSExpiration
public final void setJMSExpiration(long expiration) throws JMSExceptionAPI method. Sets the message's expiration value.This field is set when a message is sent, this method can only be used to change the value for a message that has been received.
- Specified by:
setJMSExpirationin interfaceMessage- Parameters:
expiration- the message's expiration time.- Throws:
JMSException- Actually never thrown.
-
getJMSRedelivered
public final boolean getJMSRedelivered() throws JMSExceptionAPI method. Gets an indication of whether this message is being redelivered.If a client receives a message with the JMSRedelivered field set, it can access the JMSXDeliveryCount property to determine the number of attempts to deliver this message.
- Specified by:
getJMSRedeliveredin interfaceMessage- Returns:
- true if this message is being redelivered.
- Throws:
JMSException- Actually never thrown.
-
setJMSRedelivered
public final void setJMSRedelivered(boolean redelivered) throws JMSExceptionAPI method. Specifies whether this message is being redelivered.This field is set at the time the message is delivered, this method can only be used to change the value for a message that has been received.
- Specified by:
setJMSRedeliveredin interfaceMessage- Parameters:
redelivered- an indication of whether this message is being redelivered.- Throws:
JMSException- Actually never thrown.
-
getJMSReplyTo
public final Destination getJMSReplyTo() throws JMSException
API method. Gets the Destination object to which a reply to this message should be sent.- Specified by:
getJMSReplyToin interfaceMessage- Returns:
- Destination to which to send a response to this message.
- Throws:
JMSException- Actually never thrown.
-
setJMSReplyTo
public final void setJMSReplyTo(Destination replyTo) throws JMSException
API method. Sets the Destination object to which a reply to this message should be sent.The JMSReplyTo header field contains the destination where a reply to the current message should be sent. The destination may be either a Queue object or a Topic object.
- Specified by:
setJMSReplyToin interfaceMessage- Parameters:
replyTo- Destination to which to send a response to this message.- Throws:
JMSException- If the destination id not a Joram's one.
-
getJMSTimestamp
public final long getJMSTimestamp() throws JMSExceptionAPI method. Returns the message time stamp.The JMSTimestamp header field contains the time a message was handed off to Joram to be sent. It is not the time the message was actually transmitted, because the actual send may occur later due to transactions or other client-side queueing of messages.
When a message is sent, JMSTimestamp is ignored. When the send or publish method returns, it contains a time value somewhere in the interval between the call and the return.
Since timestamps take some effort to create and increase a message's size, some Joram allows to optimize message overhead if they are given a hint that the timestamp is not used by an application. By calling the MessageProducer.setDisableMessageTimestamp method, a JMS client enables this potential optimization for all messages sent by that message producer.
- Specified by:
getJMSTimestampin interfaceMessage- Returns:
- the message timestamp.
- Throws:
JMSException- Actually never thrown.
-
setJMSTimestamp
public final void setJMSTimestamp(long timestamp) throws JMSExceptionAPI method. Sets the message timestamp.This field is set when a message is sent, this method can only be used to change the value for a message that has been received.
- Specified by:
setJMSTimestampin interfaceMessage- Parameters:
timestamp- the timestamp for this message.- Throws:
JMSException- Actually never thrown.
-
getJMSCorrelationID
public final String getJMSCorrelationID() throws JMSException
API method. Returns the message correlation identifier.- Specified by:
getJMSCorrelationIDin interfaceMessage- Returns:
- the correlation ID for the message.
- Throws:
JMSException- Actually never thrown.
-
setJMSCorrelationID
public final void setJMSCorrelationID(String correlationID) throws JMSException
API method. Sets the correlation identifier for the message.A client can use the JMSCorrelationID header field to link one message with another. A typical use is to link a response message with its request message.
- Specified by:
setJMSCorrelationIDin interfaceMessage- Parameters:
correlationID- the message ID of a message being referred to.- Throws:
JMSException- Actually never thrown.
-
getJMSCorrelationIDAsBytes
public final byte[] getJMSCorrelationIDAsBytes() throws JMSExceptionAPI method. Gets the correlation ID as an array of bytes for the message.- Specified by:
getJMSCorrelationIDAsBytesin interfaceMessage- Returns:
- the correlation ID for the message as an array of bytes.
- Throws:
JMSException- Actually never thrown.
-
setJMSCorrelationIDAsBytes
public final void setJMSCorrelationIDAsBytes(byte[] correlationID) throws JMSExceptionAPI method. Sets the correlation ID as an array of bytes for the message.The use of a byte[] value for JMSCorrelationID is non-portable.
- Specified by:
setJMSCorrelationIDAsBytesin interfaceMessage- Parameters:
correlationID- the message ID value as an array of bytes.- Throws:
JMSException- Actually never thrown.
-
getJMSDeliveryMode
public final int getJMSDeliveryMode() throws JMSExceptionAPI method. Gets the DeliveryMode value specified for this message.The delivery modes supported are DeliveryMode.PERSISTENT and DeliveryMode.NON_PERSISTENT.
- Specified by:
getJMSDeliveryModein interfaceMessage- Returns:
- the delivery mode for this message.
- Throws:
JMSException- Actually never thrown.- See Also:
DeliveryMode
-
setJMSDeliveryMode
public final void setJMSDeliveryMode(int deliveryMode) throws JMSExceptionAPI method. Sets the DeliveryMode value for this message.JMS providers set this field when a message is sent. This method can be used to change the value for a message that has been received.
- Specified by:
setJMSDeliveryModein interfaceMessage- Parameters:
deliveryMode- the delivery mode for this message.- Throws:
JMSException- If the delivery mode is incorrect.
-
getJMSType
public final String getJMSType() throws JMSException
API method. Gets the message type identifier supplied by the client when the message was sent.- Specified by:
getJMSTypein interfaceMessage- Returns:
- the message type
- Throws:
JMSException- Actually never thrown.
-
setJMSType
public final void setJMSType(String type) throws JMSException
API method. Sets the message type.Joram does not define a standard message definition repository, this field can be used freely by the JMS applications.
- Specified by:
setJMSTypein interfaceMessage- Parameters:
type- the message type.- Throws:
JMSException- Actually never thrown.
-
clearProperties
public final void clearProperties() throws JMSExceptionAPI method. Clears the message's properties.- Specified by:
clearPropertiesin interfaceMessage- Throws:
JMSException- Actually never thrown.
-
resetPropertiesRO
public final void resetPropertiesRO() throws JMSExceptionResets the read-only flag, in order to allow the modification of message properties.- Throws:
JMSException- Actually never thrown.
-
propertyExists
public final boolean propertyExists(String name) throws JMSException
API method. Indicates whether a property value exists.- Specified by:
propertyExistsin interfaceMessage- Parameters:
name- the name of the property to test.- Returns:
- true if the property exists.
- Throws:
JMSException- Actually never thrown.
-
getProperties
public void getProperties(Map h)
Copies all of the mappings from the properties of this message to the specified map. These mappings will replace any mappings that this Map had for any of the keys currently in the properties.
-
getPropertyNames
public final Enumeration getPropertyNames() throws JMSException
API method. Returns an Enumeration of all the property names.Note that JMS standard header fields are not considered properties and are not returned in this enumeration.
- Specified by:
getPropertyNamesin interfaceMessage- Returns:
- An enumeration of all the names of property values.
- Throws:
JMSException- Actually never thrown.
-
setBooleanProperty
public final void setBooleanProperty(String name, boolean value) throws JMSException
API method. Sets a boolean property value with the specified name into the message.- Specified by:
setBooleanPropertyin interfaceMessage- Parameters:
name- The property name.value- The property value.- Throws:
MessageNotWriteableException- If the message is read-only.JMSException- If the property name is invalid.
-
setByteProperty
public final void setByteProperty(String name, byte value) throws JMSException
API method. Sets a byte property value with the specified name into the message.- Specified by:
setBytePropertyin interfaceMessage- Parameters:
name- The property name.value- The property value.- Throws:
MessageNotWriteableException- If the message is read-only.JMSException- If the property name is invalid.
-
setShortProperty
public final void setShortProperty(String name, short value) throws JMSException
API method. Sets a short property value with the specified name into the message.- Specified by:
setShortPropertyin interfaceMessage- Parameters:
name- The property name.value- The property value.- Throws:
MessageNotWriteableException- If the message is read-only.JMSException- If the property name is invalid.
-
setIntProperty
public final void setIntProperty(String name, int value) throws JMSException
API method. Sets an int property value with the specified name into the message.- Specified by:
setIntPropertyin interfaceMessage- Parameters:
name- The property name.value- The property value.- Throws:
MessageNotWriteableException- If the message is read-only.JMSException- If the property name is invalid.
-
setLongProperty
public final void setLongProperty(String name, long value) throws JMSException
API method. Sets a long property value with the specified name into the message.- Specified by:
setLongPropertyin interfaceMessage- Parameters:
name- The property name.value- The property value.- Throws:
MessageNotWriteableException- If the message is read-only.JMSException- If the property name is invalid.
-
setFloatProperty
public final void setFloatProperty(String name, float value) throws JMSException
API method. Sets a floaf property value with the specified name into the message.- Specified by:
setFloatPropertyin interfaceMessage- Parameters:
name- The property name.value- The property value.- Throws:
MessageNotWriteableException- If the message is read-only.JMSException- If the property name is invalid.
-
setDoubleProperty
public final void setDoubleProperty(String name, double value) throws JMSException
API method. Sets a double property value with the specified name into the message.- Specified by:
setDoublePropertyin interfaceMessage- Parameters:
name- The property name.value- The property value.- Throws:
MessageNotWriteableException- If the message is read-only.JMSException- If the property name is invalid.
-
setStringProperty
public final void setStringProperty(String name, String value) throws JMSException
API method. Sets a String property value with the specified name into the message.- Specified by:
setStringPropertyin interfaceMessage- Parameters:
name- The property name.value- The property value.- Throws:
MessageNotWriteableException- If the message is read-only.JMSException- If the property name is invalid.
-
setObjectProperty
public final void setObjectProperty(String name, Object value) throws JMSException
API method. Sets an object property value.Note that this method works only for the objectified primitive object types (Integer, Double, Long ...) and String objects.
- Specified by:
setObjectPropertyin interfaceMessage- Parameters:
name- The property name.value- The property value.- Throws:
IllegalArgumentException- If the key name is illegal (null or empty string).MessageFormatException- If the value is not a Java primitive object.MessageNotWriteableException- If the message is read-only.JMSException- If the property name is invalid, or if the object is invalid.
-
checkIdentifier
private final void checkIdentifier(String identifier) throws IllegalArgumentException
- Throws:
IllegalArgumentException
-
initStrictVerification
private static final void initStrictVerification()
-
strictVerificationError
private static final boolean strictVerificationError()
-
strictVerificationWarn
private static final boolean strictVerificationWarn()
-
doSetProperty
private final void doSetProperty(String name, Object value) throws JMSException
Method actually setting a new property.- Parameters:
name- The property name.value- The property value.- Throws:
MessageFormatException- If the property type is invalid.MessageNotWriteableException- If the message is read-only.JMSException- If the name is invalid.IllegalArgumentException- If the name string is null or empty.
-
getBooleanProperty
public final boolean getBooleanProperty(String name) throws JMSException
API method. Returns the value of the boolean property with the specified name.- Specified by:
getBooleanPropertyin interfaceMessage- Parameters:
name- The property name.- Returns:
- the property value for the specified name.
- Throws:
MessageFormatException- If the property type is invalid.JMSException- If the name is invalid.
-
getByteProperty
public final byte getByteProperty(String name) throws JMSException
API method. Returns the value of the byte property with the specified name.- Specified by:
getBytePropertyin interfaceMessage- Parameters:
name- The property name.- Returns:
- the property value for the specified name.
- Throws:
MessageFormatException- If the property type is invalid.JMSException- If the name is invalid.
-
getShortProperty
public final short getShortProperty(String name) throws JMSException
API method. Returns the value of the short property with the specified name.- Specified by:
getShortPropertyin interfaceMessage- Parameters:
name- The property name.- Returns:
- the property value for the specified name.
- Throws:
MessageFormatException- If the property type is invalid.JMSException- If the name is invalid.
-
getIntProperty
public final int getIntProperty(String name) throws JMSException
API method. Returns the value of the int property with the specified name.- Specified by:
getIntPropertyin interfaceMessage- Parameters:
name- The property name.- Returns:
- the property value for the specified name.
- Throws:
MessageFormatException- If the property type is invalid.JMSException- If the name is invalid.
-
getLongProperty
public final long getLongProperty(String name) throws JMSException
API method. Returns the value of the long property with the specified name.- Specified by:
getLongPropertyin interfaceMessage- Parameters:
name- The property name.- Returns:
- the property value for the specified name.
- Throws:
MessageFormatException- If the property type is invalid.JMSException- If the name is invalid.
-
getFloatProperty
public final float getFloatProperty(String name) throws JMSException
API method. Returns the value of the float property with the specified name.- Specified by:
getFloatPropertyin interfaceMessage- Parameters:
name- The property name.- Returns:
- the property value for the specified name.
- Throws:
MessageFormatException- If the property type is invalid.JMSException- If the name is invalid.
-
getDoubleProperty
public final double getDoubleProperty(String name) throws JMSException
API method. Returns the value of the double property with the specified name.- Specified by:
getDoublePropertyin interfaceMessage- Parameters:
name- The property name.- Returns:
- the property value for the specified name.
- Throws:
MessageFormatException- If the property type is invalid.JMSException- If the name is invalid.
-
getStringProperty
public final String getStringProperty(String name) throws JMSException
API method. Returns the value of the String property with the specified name.- Specified by:
getStringPropertyin interfaceMessage- Parameters:
name- The property name.- Returns:
- the property value for the specified name.
- Throws:
MessageFormatException- If the property type is invalid.JMSException- If the name is invalid.
-
getObjectProperty
public final Object getObjectProperty(String name) throws JMSException
API method. Returns the value of the object property with the specified name.This method can be used to return, in objectified format, an object that has been stored as a property in the message with the equivalent setObjectProperty method call, or its equivalent primitive settypeProperty method.
- Specified by:
getObjectPropertyin interfaceMessage- Parameters:
name- The property name.- Returns:
- the Java object property value with the specified name, in objectified format; if there is no property by this name, a null value is returned.
- Throws:
JMSException- If the name is invalid.
-
doGetProperty
private final Object doGetProperty(String name)
Method actually getting a property.- Parameters:
name- The property name.- Returns:
- the property value for the specified name.
-
convertJMSMessage
public static Message convertJMSMessage(Message jmsMsg) throws JMSException
Converts a non-Joram JMS message into a Joram message. Can be used to duplicate a message.- Parameters:
jmsMsg- a JMS message.- Returns:
- a Joram message.
- Throws:
JMSException- If an error occurs while building the message.
-
prepareJMSMessage
public static void prepareJMSMessage(Message msg) throws JMSException
Prepare a JMS message for sending.- Throws:
JMSException
-
prepare
protected void prepare() throws JMSExceptionMethod preparing the message for sending; resets header values, and serializes the body (done in subclasses).- Throws:
JMSException
-
getMomMsg
public org.objectweb.joram.shared.messages.Message getMomMsg()
- Returns:
- the momMsg
-
toString
public void toString(StringBuffer strbuf)
-
getRawBody
public byte[] getRawBody() throws IOExceptionReturns the message body in raw format.- Returns:
- the message body in raw format.
- Throws:
IOException- An error occurs during body access.
-
dumpBody
public String dumpBody() throws IOException
Returns an hex + ascii dump of the message body.- Returns:
- The dump
- Throws:
IOException- An error occurs during body access.
-
dumpBody
public Appendable dumpBody(Appendable strbuf) throws IOException
Appends an hex + ascii dump of the message body to the buffer.- Parameters:
strbuf-- Returns:
- The buffer appended
- Throws:
IOException- An error occurs during body access.
-
isBodyAssignableTo
public boolean isBodyAssignableTo(Class c) throws JMSException
API 2.0 method- Specified by:
isBodyAssignableToin interfaceMessage- Parameters:
c- the specified type Check if the message body is capable of being assigned to specified type- Returns:
- true if Message is TextMessage or MapMessage, or BytesMessage, or ObjectMessage when it's deserializable false otherwise
- Throws:
JMSException- if fail to return a value due to some internal error
-
getBody
public <T> T getBody(Class<T> c) throws JMSException
Returns the message body as an object of the specified type. This method may be called on any type of message except for StreamMessage. The message body must be capable of being assigned to the specified type. This means that the specified class or interface must be either the same as, or a superclass or superinterface of, the class of the message body.- Specified by:
getBodyin interfaceMessage- Parameters:
c- The type to which the message body will be assigned. If the message has no body then any type may be specified and null is returned.
If the message is aTextMessagethen this parameter must be set toString.classor another type to which aStringis assignable.
If the message is aObjectMessagethen parameter must be set tojava.io.Serializable.classor another type to which the body is assignable.
If the message is aMapMessagethen this parameter must be set tojava.util.Map.class(orjava.lang.Object.class).
If the message is aBytesMessagethen this parameter must be set tobyte[].class(orjava.lang.Object.class). This method will reset theBytesMessagebefore and after use.
If the message is aTextMessage,ObjectMessage,MapMessageorBytesMessageand the message has no body, then the above does not apply and this parameter may be set to any type; the returned value will always be null.
If the message is aMessage(but not one of its subtypes) then this parameter may be set to any type; the returned value will always be null.- Returns:
- the message body
- Throws:
MessageFormatException- if the message is a StreamMessage, if the message body cannot be assigned to the specified type, or if the message is an ObjectMessage and object deserialization fails.JMSException- if the JMS provider fails to get the message body due to some internal error.
-
getEffectiveBody
protected <T> T getEffectiveBody(Class<T> c) throws JMSException
Get message body- Parameters:
c- The type to which the message body will be assigned.- Returns:
- message body
- Throws:
JMSException- if the JMS provider fails to return a value due to some internal error.
-
getJMSDeliveryTime
public long getJMSDeliveryTime() throws JMSExceptionAPI 2.0 Gets the message delivery time value.- Specified by:
getJMSDeliveryTimein interfaceMessage- Returns:
- the message delivery time value.
- Throws:
JMSException- if fail to get the delivery time due to some internal error.
-
setJMSDeliveryTime
public void setJMSDeliveryTime(long deliveryTime) throws JMSExceptionAPI 2.0 Sets the message delivery time value.- Specified by:
setJMSDeliveryTimein interfaceMessage- Parameters:
deliveryTime- the message delivery time value- Throws:
JMSException- if fail to set the delivery time due to some internal error.
-
-