O'Reilly - Java Message Service
O'Reilly - Java Message Service
O'Reilly - Java Message Service
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
Appendix C. <strong>Message</strong> Properties<br />
<strong>Java</strong> <strong>Message</strong> <strong>Service</strong><br />
<strong>Message</strong> properties are additional headers that can be assigned to a message. They provide<br />
the application developer or JMS vendor with the ability to attach more information to a<br />
message. The <strong>Message</strong> interface provides several accessor and mutator methods for reading<br />
and writing properties. Properties can have a String value, or one of several primitive<br />
(boolean, byte, short, int, long, float, double) values. The naming of properties, together<br />
with their values and conversion rules, are strictly defined by JMS.<br />
C.1 Property Names<br />
Properties are name-value pairs. The name, called the identifier, can be just about any<br />
String that is a valid identifier in the <strong>Java</strong> language. With a couple of exceptions, the rules<br />
that apply to naming a property are the same as those that apply to the naming of variables.<br />
One difference between a JMS property name and a <strong>Java</strong> variable name is that a property<br />
name can be any length. In addition, property names are prohibited from using one of the<br />
message selector reserved words. These words include: NOT, AND, OR, BETWEEN, LIKE, IN, IS,<br />
NULL, TRUE, and FALSE.<br />
The property names used in JMS-defined properties and provider-specific properties use<br />
predefined prefixes. These prefixes (JMSX and JMS_) may not be used for application<br />
property names.<br />
C.2 Property Values<br />
Property values can be any boolean, byte, short, int, long, float, double, or String. The<br />
javax.jms.<strong>Message</strong> interface provides accessor and mutator methods for each of these<br />
property value types. Here is the portion of the <strong>Message</strong> interface definition that shows<br />
these methods:<br />
package javax.jms;<br />
public interface <strong>Message</strong> {<br />
public String getStringProperty(String name)<br />
throws JMSException, <strong>Message</strong>FormatException;<br />
public void setStringProperty(String name, String value)<br />
throws JMSException, <strong>Message</strong>NotWriteableException;<br />
public int getIntProperty(String name)<br />
throws JMSException, <strong>Message</strong>FormatException;<br />
public void setIntProperty(String name, int value)<br />
throws JMSException, <strong>Message</strong>NotWriteableException;<br />
public boolean getBooleanProperty(String name)<br />
throws JMSException, <strong>Message</strong>FormatException;<br />
public void setBooleanProperty(String name, boolean value)<br />
throws JMSException, <strong>Message</strong>NotWriteableException;<br />
public double getDoubleProperty(String name)<br />
throws JMSException, <strong>Message</strong>FormatException;<br />
public void setDoubleProperty(String name, double value)<br />
throws JMSException, <strong>Message</strong>NotWriteableException;<br />
public float getFloatProperty(String name)<br />
throws JMSException, <strong>Message</strong>FormatException;<br />
public void setFloatProperty(String name, float value)<br />
throws JMSException, <strong>Message</strong>NotWriteableException;<br />
public byte getByteProperty(String name)<br />
throws JMSException, <strong>Message</strong>FormatException;<br />
167