Class JMSMessage
- java.lang.Object
-
- com.ibm.jms.JMSMessage
-
- All Implemented Interfaces:
- JmsMessage, java.io.Serializable, javax.jms.Message
- Direct Known Subclasses:
- JMSBytesMessage, JMSMapMessage, JMSObjectMessage, JMSStreamMessage, JMSTextMessage
public class JMSMessage extends java.lang.Object implements javax.jms.Message, java.io.Serializable, JmsMessage
The Message interface is the root interface of all JMS messages. It defines the JMS header and the acknowledge() method used for all messages. The header contains fields used for message routing and identification. The payload contains the application data being sent.
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 application defined message filtering.
- Body: JMS defines several types of message body which cover the majority of messaging styles currently in use.
JMS defines five types of message body:
- Stream: a stream of Java primitive values. It is filled and read sequentially.
- Map: a set of name-value pairs where names are Strings and values are Java primitive types. The entries can be accessed sequentially or randomly by name. The order of the entries is undefined.
- Text: a message containing a
java.util.StringBuffer. The inclusion of this message type allows XML to represent content of all kinds, including the content of JMS messages. - Object: a message that contains a Serializable java object
- Bytes: a stream of uninterpreted bytes. This message type is for literally encoding a body to match an existing message format. In many cases, it will be possible to use one of the other, easier to use, body types instead. Although JMS allows the use of message properties with byte messages, it is typically not done since the inclusion of properties might affect the format.
The JMSCorrelationID header field is used to link one message with another. It typically links a reply message with its requesting message. A JMSCorrelationID can hold either a provider-specific message ID, an application-specific String, or a provider-specific byte[] value.
A Message contains a built-in facility for supporting application-defined property values. In effect, this provides a mechanism for adding application-specific header fields to a message. Properties allow an application, via message selectors, to have a JMS provider select and filter messages on its behalf using application-specific criteria. Property names must obey the rules for the selector identifier of a message. Property values can be boolean, byte, short, int, long, float, double, and String.
Property values are set prior to sending a message. When a client receives a message, its properties are in read-only mode. If a client attempts to set properties at this point, a MessageNotWriteableException is thrown. If clearProperties() is called, the properties can then be both read from and written to.
A property value might duplicate a value in a message's body or it might not. Although JMS does not define a policy for what might be made a property, JMS handles data in a message's body more efficiently than data in a message's properties. For best performance, applications should only use message properties when they need to customize a message's header. The primary reason for doing this is to support customized message selection.
Message properties support the following conversion table. The marked cases are supported. The unmarked cases throw a JMSException. The String to primitive conversions might throw a runtime exception if the primitives valueOf() method does not accept it as a valid String representation of the primitive.
A value written as the row type can be read as the column type.
boolean byte short char int long float double String boolean X X byte X X X X X short X X X X char X X int X X X long X X float X X X double X X String X X X X X X X X In addition to the type-specific set and get methods for properties, JMS provides the setObjectProperty() and getObjectProperty() methods. These support the same set of property types using the 'objectified' primitive values. Their purpose is to allow the property type to be decided at execution time rather than at compile time. They support the same property value conversions.
The setObjectProperty() method accepts values of class Boolean, Byte, Short, Integer, Long, Float, Double and String. An attempt to use any other class throws a JMSException. The getObjectProperty() method only returns values of class Boolean, Byte, Short, Integer, Long, Float, Double and String.
The order of property values is not defined. To iterate through a message's property values, use getPropertyNames() to retrieve a property name Enumeration and then use the various property accessor methods to retrieve their values.
A message's properties are deleted by the clearProperties() method. This leaves the message with an empty set of properties.
Getting a property value for a name which has not been set returns a null value. Only the getStringProperty() and getObjectProperty() methods can return a null value. The other property get methods throw a java.lang.NullPointerException if they are used to get a nonexistent property.
JMS reserves the
JMSX
property name prefix for JMS defined properties. The full set of these properties is defined in the Java Message Service specification. The String[] ConnectionMetaData.getJMSXPropertyNames() method returns the names of the JMSX properties supported by a connection. JMSX properties can be referenced in message selectors whether or not they are supported by a connection. They are treated like any other absent property.JSMX properties
set by provider on send
are available to both the producer and the consumers of the message. JSMX propertiesset by provider on receive
are only available to the consumers.JMSXGroupID and JMSXGroupSeq are simply standard properties that clients can use if they want to group messages.
JMS reserves the
JMS_
property name prefix.If an application tries to set a message property with a name that commences JMS, but the name is not one of the names in the following list, IBM MQ JMS throws an exception:
- JMSXGroupID
- JJMSXGroupSeq
- JMS_IBM_Format
- JMS_IBM_MsgType
- JMS_IBM_Feedback
- JMS_IBM_PutApplType
- JMS_IBM_Report_Exception
- JMS_IBM_Report_Expiration
- JMS_IBM_Report_COA
- JMS_IBM_Report_COD
- JMS_IBM_Report_PAN
- JMS_IBM_Report_NAN
- JMS_IBM_Report_Pass_Msg_ID
- JMS_IBM_Report_Pass_Correl_ID
- JMS_IBM_Report_Discard_Msg
- JMS_IBM_Last_Msg_In_Group
- JMS_IBM_PutDate
- JMS_IBM_PutTime
- See Also:
- Serialized Form
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidacknowledge()Acknowledges this and all previous messages received.voidclearBody()Clears out the message body.voidclearProperties()Clears a message's properties.<T> TgetBody(java.lang.Class<T> c)Returns the message body as an object of the specified typebooleangetBooleanProperty(java.lang.String name)Gets the boolean property value with the given name.bytegetByteProperty(java.lang.String name)Gets the byte property value with the given name.doublegetDoubleProperty(java.lang.String name)Gets the double property value with the given name.floatgetFloatProperty(java.lang.String name)Gets the float property value with the given name.intgetIntProperty(java.lang.String name)Gets the integer property value with the given name.java.lang.StringgetJMSCorrelationID()Gets the correlation ID for the message.byte[]getJMSCorrelationIDAsBytes()Gets the correlation ID as an array of bytes for the message.intgetJMSDeliveryMode()Gets the delivery mode for this message.longgetJMSDeliveryTime()Gets the message's delivery time value.javax.jms.DestinationgetJMSDestination()Gets the destination for this message.longgetJMSExpiration()Gets the message's expiration value.java.lang.StringgetJMSMessageID()Gets the message ID.intgetJMSPriority()Gets the message priority.booleangetJMSRedelivered()Gets an indication of whether this message is being redelivered.javax.jms.DestinationgetJMSReplyTo()Gets the destination to which a reply to this message should be sent.longgetJMSTimestamp()Gets the message timestamp.java.lang.StringgetJMSType()Gets the message type.longgetLongProperty(java.lang.String name)Gets the long property value with the given name.java.lang.ObjectgetObjectProperty(java.lang.String name)Gets the Java object property value with the given name.java.util.Enumeration<?>getPropertyNames()Gets an Enumeration of all the property names.shortgetShortProperty(java.lang.String name)Gets the short property value with the given name.java.lang.StringgetStringProperty(java.lang.String name)Gets the String property value with the given name.booleanisBodyAssignableTo(java.lang.Class c)Returns whether the message body is capable of being assigned to the specified type.booleanpropertyExists(java.lang.String name)Indicates whether a named property exists in the message properties hashtable.voidsetBooleanProperty(java.lang.String name, boolean value)Sets a boolean property value with the given name in the message.voidsetByteProperty(java.lang.String name, byte value)Sets a byte property value with the given name in the message.voidsetDoubleProperty(java.lang.String name, double value)Sets a double property value with the given name in the message.voidsetFloatProperty(java.lang.String name, float value)Sets a float property value with the given name in the message.voidsetIntProperty(java.lang.String name, int value)Sets an integer property value with the given name in the message.voidsetJMSCorrelationID(java.lang.String correlationID)Sets the correlation ID for the message.voidsetJMSCorrelationIDAsBytes(byte[] correlID)Sets the correlation ID as an array of bytes for the message.voidsetJMSDeliveryMode(int deliveryMode)Sets the delivery mode for this message.voidsetJMSDeliveryTime(long deliveryTime)Sets the message's delivery time value.voidsetJMSDestination(javax.jms.Destination destination)Sets the destination for this message.voidsetJMSExpiration(long expiration)Sets the message's expiration value.voidsetJMSMessageID(java.lang.String id)Sets the message ID.voidsetJMSPriority(int priority)Sets the priority for this message.voidsetJMSRedelivered(boolean redelivered)Sets a boolean to indicate whether this message is being redelivered.voidsetJMSReplyTo(javax.jms.Destination replyTo)Sets the destination to which a reply to this message should be sent.voidsetJMSTimestamp(long timestamp)Sets the message timestamp.voidsetJMSType(java.lang.String type)Sets the message type.voidsetLongProperty(java.lang.String name, long value)Sets a long property value with the given name in the message.voidsetObjectProperty(java.lang.String name, java.lang.Object value)Sets a Java object property value with the given name into the message.voidsetShortProperty(java.lang.String name, short value)Sets a short property value with the given name in the message.voidsetStringProperty(java.lang.String name, java.lang.String value)Sets a String property value with the given name in the message.java.lang.StringtoString()Gets a String containing a formatted version of the message header.voidupdateFromMessage(javax.jms.Message message)Updates the properties of this message with all the details of the JmsMessage passed to it.-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.ibm.msg.client.jms.JmsMessage
getDelegate
-
-
-
-
Method Detail
-
acknowledge
public void acknowledge() throws javax.jms.JMSExceptionAcknowledges this and all previous messages received. Calling this method also acknowledges all other messages received by the Session that received this message.- Specified by:
acknowledgein interfacejavax.jms.Message- Throws:
javax.jms.JMSException- if the operation fails
-
clearBody
public void clearBody() throws javax.jms.JMSExceptionClears out the message body. All other parts of the message are left untouched.- Specified by:
clearBodyin interfacejavax.jms.Message- Throws:
javax.jms.JMSException- if an internal error occurs.
-
clearProperties
public void clearProperties() throws javax.jms.JMSExceptionClears a message's properties.- Specified by:
clearPropertiesin interfacejavax.jms.Message- Throws:
javax.jms.JMSException- if an internal error occurs
-
getBooleanProperty
public boolean getBooleanProperty(java.lang.String name) throws javax.jms.JMSExceptionGets the boolean property value with the given name.- Specified by:
getBooleanPropertyin interfacejavax.jms.Message- Parameters:
name- the name of the boolean property- Returns:
- the boolean property value with the given name
- Throws:
javax.jms.MessageFormatException- if this type conversion is invalidjavax.jms.JMSException- if the property name is null or if the operation fails for an internal reason
-
getByteProperty
public byte getByteProperty(java.lang.String name) throws javax.jms.JMSExceptionGets the byte property value with the given name.- Specified by:
getBytePropertyin interfacejavax.jms.Message- Parameters:
name- the name of the byte property.- Returns:
- the byte property value with the given name
- Throws:
javax.jms.MessageFormatException- if this type conversion is not validjavax.jms.JMSException- if the property name is null or if the operation fails for an internal reason
-
getDoubleProperty
public double getDoubleProperty(java.lang.String name) throws javax.jms.JMSExceptionGets the double property value with the given name.- Specified by:
getDoublePropertyin interfacejavax.jms.Message- Parameters:
name- the name of the double property- Returns:
- the double property value with the given name
- Throws:
javax.jms.MessageFormatException- if this type conversion is not validjavax.jms.JMSException- if the property name is null or if the operation fails for an internal reason
-
getFloatProperty
public float getFloatProperty(java.lang.String name) throws javax.jms.JMSExceptionGets the float property value with the given name.- Specified by:
getFloatPropertyin interfacejavax.jms.Message- Parameters:
name- the name of the float property- Returns:
- the float property value with the given name
- Throws:
javax.jms.MessageFormatException- if this type conversion is not validjavax.jms.JMSException- if the property name is null or if the operation fails for an internal reason
-
getIntProperty
public int getIntProperty(java.lang.String name) throws javax.jms.JMSExceptionGets the integer property value with the given name.- Specified by:
getIntPropertyin interfacejavax.jms.Message- Parameters:
name- the name of the integer property- Returns:
- the integer property value with the given name.
- Throws:
javax.jms.MessageFormatException- if this type conversion is not validjavax.jms.JMSException- if the property name is null or if the operation fails for an internal reason
-
getJMSCorrelationID
public java.lang.String getJMSCorrelationID() throws javax.jms.JMSExceptionGets the correlation ID for the message.This method is used to return correlation ID values that are either provider-specific message IDs or application-specific Strings.
- Specified by:
getJMSCorrelationIDin interfacejavax.jms.Message- Returns:
- the correlation ID of the message as a String
- Throws:
javax.jms.JMSException- if the operation fails- See Also:
setJMSCorrelationID(java.lang.String)
-
getJMSCorrelationIDAsBytes
public byte[] getJMSCorrelationIDAsBytes() throws javax.jms.JMSExceptionGets the correlation ID as an array of bytes for the message. The use of a byte[] value for JMSCorrelationID is not portable.
- Specified by:
getJMSCorrelationIDAsBytesin interfacejavax.jms.Message- Returns:
- the correlation ID of a message as an array of bytes
- Throws:
javax.jms.JMSException- if an internal error occurs.
-
getJMSDeliveryMode
public int getJMSDeliveryMode() throws javax.jms.JMSExceptionGets the delivery mode for this message.- Specified by:
getJMSDeliveryModein interfacejavax.jms.Message- Returns:
- the delivery mode of this message
- Throws:
javax.jms.JMSException- if an internal error occurs
-
getJMSDestination
public javax.jms.Destination getJMSDestination() throws javax.jms.JMSExceptionGets the destination for this message.The destination field contains the destination to which the message is being sent.
When a message is sent, this value is ignored. After completion of the send() method it holds the destination specified by the send().
When a message is received, its destination value must be equivalent to the value assigned when it was sent.
- Specified by:
getJMSDestinationin interfacejavax.jms.Message- Returns:
- the destination of this message
- Throws:
javax.jms.JMSException- if the destination is invalid
-
getJMSExpiration
public long getJMSExpiration() throws javax.jms.JMSExceptionGets the message's expiration value.When a message is sent, expiration is left unassigned. After completion of the send method, it holds the expiration time of the message. This is the time-to-live value specified by the client added to the time (GMT) when the message was sent.
If the time-to-live is specified as zero, expiration is set to zero which indicates the message does not expire.
When a message's expiration time is reached, a provider should discard it. JMS does not define any form of notification of message expiration.
Clients might receive messages that have expired: JMS does not guarantee that this will not happen.
- Specified by:
getJMSExpirationin interfacejavax.jms.Message- Returns:
- the time (GMT) when the message expires
- Throws:
javax.jms.JMSException- if an internal error occurs
-
getJMSMessageID
public java.lang.String getJMSMessageID() throws javax.jms.JMSExceptionGets the message ID.The messageID header field contains a value that uniquely identifies each message sent by a provider.
When a message is sent, messageID can be ignored. When the send() method returns, it contains a provider-assigned value.
A JMSMessageID is a String value which functions as a unique key for identifying messages in a historical repository. The exact scope of uniqueness is provider defined. It should at least cover all messages for a specific installation of a provider where an installation is some connected set of message routers.
All JMSMessageID values must start with the prefix
ID:
. Uniqueness of message ID values across different providers is not required.- Specified by:
getJMSMessageIDin interfacejavax.jms.Message- Returns:
- the message ID
- Throws:
javax.jms.JMSException- if an internal error occurs
-
getJMSPriority
public int getJMSPriority() throws javax.jms.JMSExceptionGets the message priority.JMS defines ten levels of priority with 0 as the lowest 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.
- Specified by:
getJMSPriorityin interfacejavax.jms.Message- Returns:
- the default message priority
- Throws:
javax.jms.JMSException- if an internal error occurs
-
getJMSRedelivered
public boolean getJMSRedelivered() throws javax.jms.JMSExceptionGets an indication of whether this message is being redelivered.If a client receives a message with the redelivered indicator set, it is likely, but not guaranteed, that this message was delivered to the client earlier but the client did not acknowledge its receipt at that earlier time.
- Specified by:
getJMSRedeliveredin interfacejavax.jms.Message- Returns:
- set to true if this message is being redelivered, false otherwise
- Throws:
javax.jms.JMSException- if an internal error occurs
-
getJMSReplyTo
public javax.jms.Destination getJMSReplyTo() throws javax.jms.JMSExceptionGets the destination to which a reply to this message should be sent.- Specified by:
getJMSReplyToin interfacejavax.jms.Message- Returns:
- where to send a response to this message
- Throws:
javax.jms.JMSException- if the destination is invalid
-
getJMSTimestamp
public long getJMSTimestamp() throws javax.jms.JMSExceptionGets the message timestamp.The JMSTimestamp header field contains the time a message was handed to a provider to be sent. It is not the time the message was actually transmitted because that might occur later due to transactions or other client-side queueing of messages.
When a message is sent, JMSTimestamp is ignored. When the send method returns, it contains a time somewhere between the call and the return. It is in the format of a normal Java millisecond time value.
- Specified by:
getJMSTimestampin interfacejavax.jms.Message- Returns:
- the message timestamp
- Throws:
javax.jms.JMSException- if an internal error occurs
-
getJMSType
public java.lang.String getJMSType() throws javax.jms.JMSExceptionGets the message type.- Specified by:
getJMSTypein interfacejavax.jms.Message- Returns:
- the message type
- Throws:
javax.jms.JMSException- if an internal error occurs
-
getLongProperty
public long getLongProperty(java.lang.String name) throws javax.jms.JMSExceptionGets the long property value with the given name.- Specified by:
getLongPropertyin interfacejavax.jms.Message- Parameters:
name- the name of the long property- Returns:
- the long property value with the given name
- Throws:
javax.jms.MessageFormatException- if this type conversion is not validjavax.jms.JMSException- if the property name is null or if the operation fails for an internal reason
-
getObjectProperty
public java.lang.Object getObjectProperty(java.lang.String name) throws javax.jms.JMSExceptionGets the Java object property value with the given name.This method can be used to return, in objectified format, an object that had been stored as a property in the Message with the equivalent setObject() method call, or its equivalent primitive setter method.
- Specified by:
getObjectPropertyin interfacejavax.jms.Message- Parameters:
name- the name of the Java object property.- Returns:
- the Java object property value with the given name in objectified format (that is, if
it set as an
int, then an Integer is returned). If there is no property with this name, a null value is returned. - Throws:
javax.jms.JMSException- if the property name is null or if the operation fails for an internal reason- See Also:
setObjectProperty(java.lang.String, java.lang.Object)
-
getPropertyNames
public java.util.Enumeration<?> getPropertyNames() throws javax.jms.JMSExceptionGets an Enumeration of all the property names.- Specified by:
getPropertyNamesin interfacejavax.jms.Message- Returns:
- an Enumeration of all the property names
- Throws:
javax.jms.JMSException- if an internal error occurs
-
getShortProperty
public short getShortProperty(java.lang.String name) throws javax.jms.JMSExceptionGets the short property value with the given name.- Specified by:
getShortPropertyin interfacejavax.jms.Message- Parameters:
name- the name of the short property- Returns:
- the short property value with the given name
- Throws:
javax.jms.JMSException- if the property name is null or if the operation fails for an internal reason
-
getStringProperty
public java.lang.String getStringProperty(java.lang.String name) throws javax.jms.JMSExceptionGets the String property value with the given name.- Specified by:
getStringPropertyin interfacejavax.jms.Message- Parameters:
name- the name of the String property to retrieve- Returns:
- the String property value with the given name
- Throws:
javax.jms.JMSException- if the property name is null or if the operation fails for an internal reason
-
propertyExists
public boolean propertyExists(java.lang.String name) throws javax.jms.JMSExceptionIndicates whether a named property exists in the message properties hashtable.- Specified by:
propertyExistsin interfacejavax.jms.Message- Parameters:
name- the name of the property to test.- Returns:
- true if the property exists, false if it does not.
- Throws:
javax.jms.JMSException- with reason if the property name is null
-
setBooleanProperty
public void setBooleanProperty(java.lang.String name, boolean value) throws javax.jms.JMSExceptionSets a boolean property value with the given name in the message.- Specified by:
setBooleanPropertyin interfacejavax.jms.Message- Parameters:
name- the name of the boolean propertyvalue- thebooleanproperty value to set in the Message- Throws:
javax.jms.MessageNotWriteableException- if properties are marked read-onlyjavax.jms.JMSException- if the property name is not valid
-
-
setByteProperty
public void setByteProperty(java.lang.String name, byte value) throws javax.jms.JMSExceptionSets a byte property value with the given name in the message.- Specified by:
setBytePropertyin interfacejavax.jms.Message- Parameters:
name- the name of the byte propertyvalue- thebyteproperty value to set in the Message- Throws:
javax.jms.MessageNotWriteableException- if properties are marked read-onlyjavax.jms.JMSException- if the property name is not valid
-
-
setDoubleProperty
public void setDoubleProperty(java.lang.String name, double value) throws javax.jms.JMSExceptionSets a double property value with the given name in the message.- Specified by:
setDoublePropertyin interfacejavax.jms.Message- Parameters:
name- the name of the double propertyvalue- thedoubleproperty value to set in the Message- Throws:
javax.jms.MessageNotWriteableException- if properties are marked read-onlyjavax.jms.JMSException- if the property name is not valid
-
setFloatProperty
public void setFloatProperty(java.lang.String name, float value) throws javax.jms.JMSExceptionSets a float property value with the given name in the message.- Specified by:
setFloatPropertyin interfacejavax.jms.Message- Parameters:
name- the name of the float propertyvalue- thefloatproperty value to set in the Message- Throws:
javax.jms.MessageNotWriteableException- if properties are marked read-onlyjavax.jms.JMSException- if the property name is not valid
-
setIntProperty
public void setIntProperty(java.lang.String name, int value) throws javax.jms.JMSExceptionSets an integer property value with the given name in the message.- Specified by:
setIntPropertyin interfacejavax.jms.Message- Parameters:
name- the name of the integer propertyvalue- theintproperty value to set in the Message- Throws:
javax.jms.MessageNotWriteableException- if properties are marked read-onlyjavax.jms.JMSException- if the property name is not valid
-
setJMSCorrelationID
public void setJMSCorrelationID(java.lang.String correlationID) throws javax.jms.JMSExceptionSets the correlation ID 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.
JMSCorrelationID can hold one of the following:
- A provider-specific message ID
- An application-specific String
- A provider-native byte[] value.
Since each message sent by a JMS provider is assigned a message ID, it is convenient to link messages using their message IDs. All message ID values must start with the 'ID:' prefix.
In some cases, an application (made up of several clients) needs to use an application-specific value for linking messages. For example, an application might use JMSCorrelationID to hold a value referencing some external information. Application-specified values must not start with the 'ID:' prefix; this is reserved for provider-generated message ID values.
If a provider supports the native concept of correlation ID, a JMS client might need to assign specific JMSCorrelationID values to match those expected by non-JMS clients. A byte[] value is used for this purpose. The use of a byte[] value for JMSCorrelationID is not portable.
- Specified by:
setJMSCorrelationIDin interfacejavax.jms.Message- Parameters:
correlationID- the message ID of a message being referred to- Throws:
javax.jms.JMSException- if the correlation id is invalid
-
setJMSCorrelationIDAsBytes
public void setJMSCorrelationIDAsBytes(byte[] correlID) throws javax.jms.JMSExceptionSets the correlation ID as an array of bytes for the message.If a provider supports the native concept of correlation id, a JMS client might need to assign specific JMSCorrelationID values to match those expected by non-JMS clients.
A client can use this call to set the correlationID either to a messageID from a previous message, or to an application-specific string. Application-specific strings must not start with the characters 'ID:'.
The use of a byte[] value for JMSCorrelationID is not portable.
- Specified by:
setJMSCorrelationIDAsBytesin interfacejavax.jms.Message- Parameters:
correlID- the correlation ID value as an array of bytes- Throws:
javax.jms.JMSException- if an internal error occursjava.lang.IndexOutOfBoundsException- if copying would cause access to data outside array boundsjava.lang.ArrayStoreException- if an element in the source array could not be stored into the destination array because of a type mismatchjava.lang.NullPointerException- if either source or destination is null
-
setJMSDeliveryMode
public void setJMSDeliveryMode(int deliveryMode) throws javax.jms.JMSExceptionSets the delivery mode for this message.Any value set using this method is ignored when the message is sent, but this method can be used to change the value in a received message.
To alter the delivery mode when a message is sent, use the setDeliveryMode() method on the QueueSender or TopicPublisher (this method is inherited from MessageProducer).
- Specified by:
setJMSDeliveryModein interfacejavax.jms.Message- Parameters:
deliveryMode- the delivery mode for this message- Throws:
javax.jms.JMSException- if an internal error occurs- See Also:
MQMessageProducer.setDeliveryMode(int)
-
setJMSDestination
public void setJMSDestination(javax.jms.Destination destination) throws javax.jms.JMSExceptionSets the destination for this message.Any value set using this method is ignored when the message is sent, but this method can be used to change the value in a received message.
- Specified by:
setJMSDestinationin interfacejavax.jms.Message- Parameters:
destination- the destination for this message- Throws:
javax.jms.JMSException- if an internal error occurs
-
setJMSExpiration
public void setJMSExpiration(long expiration) throws javax.jms.JMSExceptionSets the message's expiration value.Any value set using this method is ignored when the message is sent, but this method can be used to change the value in a received message.
- Specified by:
setJMSExpirationin interfacejavax.jms.Message- Parameters:
expiration- the message's expiration time- Throws:
javax.jms.JMSException- if an internal error occurs- See Also:
getJMSExpiration()
-
setJMSMessageID
public void setJMSMessageID(java.lang.String id) throws javax.jms.JMSExceptionSets the message ID.Any value set using this method is ignored when the message is sent, but this method can be used to change the value in a received message.
Because a message ID set by this method is ignored when a message is sent, an application cannot specify the message ID of an outgoing message. As a consequence, an application cannot receive a message and then forward the same message, or send a different message, with the same message ID as that of the message it has received.
- Specified by:
setJMSMessageIDin interfacejavax.jms.Message- Parameters:
id- the ID of the message.- Throws:
javax.jms.JMSException- if an internal error occurs.- See Also:
getJMSMessageID()
-
setJMSPriority
public void setJMSPriority(int priority) throws javax.jms.JMSExceptionSets the priority for this message.Providers set this field when a message is sent. This operation can be used to change the value of a message that has been received.
JMS defines a ten levels of priority with 0 as the lowest and 9 as the highest. In addition, clients must consider priorities 0-4 as gradations of normal priority, and priorities 5-9 as gradations of expedited priority.
- Specified by:
setJMSPriorityin interfacejavax.jms.Message- Parameters:
priority- the priority of this message- Throws:
javax.jms.JMSException- if an internal error occurs
-
setJMSRedelivered
public void setJMSRedelivered(boolean redelivered) throws javax.jms.JMSExceptionSets a boolean to indicate whether this message is being redelivered.This field is set at the time the message is delivered. This operation can be used to change the value of a message that has been received.
- Specified by:
setJMSRedeliveredin interfacejavax.jms.Message- Parameters:
redelivered- an indication of whether this message is being re-delivered- Throws:
javax.jms.JMSException- if an internal error occurs
-
setJMSReplyTo
public void setJMSReplyTo(javax.jms.Destination replyTo) throws javax.jms.JMSExceptionSets the destination to which a reply to this message should be sent.The replyTo header field contains the destination where a reply to the current message should be sent. If it is null, no reply is expected. The destination can be either a Queue or a Topic.
Messages with a null replyTo value are called JMS datagrams. Datagrams might contain a notification of some change in the sender (i.e. they signal a sender event) or they might just contain some data the sender thinks is of interest.
Messages with a replyTo value are typically expecting a response. A response is optional: it is up to the client to decide. These messages are called JMS requests. A message sent in response to a request is called a reply.
In some cases a client might wish to match a request it sent earlier with a reply it has just received. This can be done using the JMSCorrelationID.
- Specified by:
setJMSReplyToin interfacejavax.jms.Message- Parameters:
replyTo- where to send a response to this message- Throws:
javax.jms.JMSException- if an internal error occurs
-
setJMSTimestamp
public void setJMSTimestamp(long timestamp) throws javax.jms.JMSExceptionSets the message timestamp.Providers set this field when a message is sent. This operation can be used to change the value of a message that has been received.
- Specified by:
setJMSTimestampin interfacejavax.jms.Message- Parameters:
timestamp- the timestamp for this message- Throws:
javax.jms.JMSException- if an internal error occurs
-
setJMSType
public void setJMSType(java.lang.String type) throws javax.jms.JMSExceptionSets the message type.The type header field contains the name of a message's definition. JMS clients should assign a value whether the application makes use of it or not. This insures that it is properly set for the provider to use it, if required.
This method must only be used with JMSBytes or JMSText messages. Use with other types of JMS Message will throw an exception with error code MQJMS_EXCEPTION_BAD_VALUE (JMSCMQ1006).
- Specified by:
setJMSTypein interfacejavax.jms.Message- Parameters:
type- the class of message- Throws:
javax.jms.JMSException- if the type is invalid- See Also:
getJMSType()
-
setLongProperty
public void setLongProperty(java.lang.String name, long value) throws javax.jms.JMSExceptionSets a long property value with the given name in the message.- Specified by:
setLongPropertyin interfacejavax.jms.Message- Parameters:
name- the name of the long propertyvalue- thelongproperty value to set in the Message- Throws:
javax.jms.MessageNotWriteableException- if properties are marked read-onlyjavax.jms.JMSException- if the property name is not valid
-
setObjectProperty
public void setObjectProperty(java.lang.String name, java.lang.Object value) throws javax.jms.JMSExceptionSets a Java object property value with the given name into the message.This method only works for the primitive object wrapper classes (Integer, Double, Long ...) and for Strings.
- Specified by:
setObjectPropertyin interfacejavax.jms.Message- Parameters:
name- the name of the Java object propertyvalue- the Java object property value to set in the Message- Throws:
javax.jms.MessageNotWriteableException- if properties are marked read-onlyjavax.jms.MessageFormatException- if the class of the object is not Number or Stringjavax.jms.JMSException- if the property name is not valid
-
setShortProperty
public void setShortProperty(java.lang.String name, short value) throws javax.jms.JMSExceptionSets a short property value with the given name in the message.- Specified by:
setShortPropertyin interfacejavax.jms.Message- Parameters:
name- the name of the short propertyvalue- theshortproperty value to set in the Message- Throws:
javax.jms.MessageNotWriteableException- if properties are marked read-onlyjavax.jms.JMSException- if the property name is not valid
-
setStringProperty
public void setStringProperty(java.lang.String name, java.lang.String value) throws javax.jms.JMSExceptionSets a String property value with the given name in the message.- Specified by:
setStringPropertyin interfacejavax.jms.Message- Parameters:
name- the name of the String propertyvalue- theStringproperty value to set in the Message- Throws:
javax.jms.MessageNotWriteableException- if properties are marked read-onlyjavax.jms.JMSException- if the property name is not valid
-
toString
public java.lang.String toString()
Gets a String containing a formatted version of the message header.- Overrides:
toStringin classjava.lang.Object- Returns:
- the String version of the message header.
-
getBody
public <T> T getBody(java.lang.Class<T> c) throws javax.jms.JMSException, javax.jms.MessageFormatExceptionReturns the message body as an object of the specified type- Specified by:
getBodyin interfacejavax.jms.Message- Parameters:
c- - The type to which the message body will be assigned- Returns:
- the message body
- Throws:
javax.jms.JMSExceptionjavax.jms.MessageFormatException- See Also:
Message.getBody(Class)
-
getJMSDeliveryTime
public long getJMSDeliveryTime() throws javax.jms.JMSExceptionGets the message's delivery time value.- Specified by:
getJMSDeliveryTimein interfacejavax.jms.Message- Returns:
- the message's delivery time value
- Throws:
javax.jms.JMSException- See Also:
Message.getJMSDeliveryTime()
-
isBodyAssignableTo
public boolean isBodyAssignableTo(java.lang.Class c) throws javax.jms.JMSException, javax.jms.MessageFormatExceptionReturns whether the message body is capable of being assigned to the specified type.- Specified by:
isBodyAssignableToin interfacejavax.jms.Message- Parameters:
c- - The specified type- Returns:
- whether the message body is capable of being assigned to the specified type
- Throws:
javax.jms.JMSExceptionjavax.jms.MessageFormatException- See Also:
Message.isBodyAssignableTo(Class)
-
setJMSDeliveryTime
public void setJMSDeliveryTime(long deliveryTime) throws javax.jms.JMSExceptionSets the message's delivery time value.- Specified by:
setJMSDeliveryTimein interfacejavax.jms.Message- Parameters:
deliveryTime- the message's delivery time- Throws:
javax.jms.JMSException- See Also:
Message.setJMSDeliveryTime(long)
-
updateFromMessage
public void updateFromMessage(javax.jms.Message message) throws javax.jms.JMSExceptionDescription copied from interface:JmsMessageUpdates the properties of this message with all the details of the JmsMessage passed to it. This method is intended to be implemented in a synchronized way to avoid multiple concurrent calls resulting in a mix of different updates.- Specified by:
updateFromMessagein interfaceJmsMessage- Throws:
javax.jms.JMSException