0001: /*
0002: * @(#)Message.java 1.60 02/04/09
0003: *
0004: * Copyright 1997-2002 Sun Microsystems, Inc. All Rights Reserved.
0005: *
0006: * SUN PROPRIETARY/CONFIDENTIAL.
0007: * This software is the proprietary information of Sun Microsystems, Inc.
0008: * Use is subject to license terms.
0009: *
0010: */
0011:
0012: package javax.jms;
0013:
0014: import java.util.Enumeration;
0015: import java.util.Properties;
0016:
0017: /** The <CODE>Message</CODE> interface is the root interface of all JMS
0018: * messages. It defines the message header and the <CODE>acknowledge</CODE>
0019: * method used for all messages.
0020: *
0021: * <P>Most message-oriented middleware (MOM) products treat messages as
0022: * lightweight entities that consist
0023: * of a header and a payload. The header contains fields used for message
0024: * routing and identification; the payload contains the application data
0025: * being sent.
0026: *
0027: * <P>Within this general form, the definition of a message varies
0028: * significantly across products. It would be quite difficult for the JMS API
0029: * to support all of these message models.
0030: *
0031: * <P>With this in mind, the JMS message model has the following goals:
0032: * <UL>
0033: * <LI>Provide a single, unified message API
0034: * <LI>Provide an API suitable for creating messages that match the
0035: * format used by provider-native messaging applications
0036: * <LI>Support the development of heterogeneous applications that span
0037: * operating systems, machine architectures, and computer languages
0038: * <LI>Support messages containing objects in the Java programming language
0039: * ("Java objects")
0040: * <LI>Support messages containing Extensible Markup Language (XML) pages
0041: * </UL>
0042: *
0043: * <P>JMS messages are composed of the following parts:
0044: * <UL>
0045: * <LI>Header - All messages support the same set of header fields.
0046: * Header fields contain values used by both clients and providers to
0047: * identify and route messages.
0048: * <LI>Properties - Each message contains a built-in facility for supporting
0049: * application-defined property values. Properties provide an efficient
0050: * mechanism for supporting application-defined message filtering.
0051: * <LI>Body - The JMS API defines several types of message body, which cover
0052: * the majority of messaging styles currently in use.
0053: * </UL>
0054: *
0055: * <H4>Message Bodies</H4>
0056: *
0057: * <P>The JMS API defines five types of message body:
0058: * <UL>
0059: * <LI>Stream - A <CODE>StreamMessage</CODE> object's message body contains
0060: * a stream of primitive values in the Java programming
0061: * language ("Java primitives"). It is filled and read sequentially.
0062: * <LI>Map - A <CODE>MapMessage</CODE> object's message body contains a set
0063: * of name-value pairs, where names are <CODE>String</CODE>
0064: * objects, and values are Java primitives. The entries can be accessed
0065: * sequentially or randomly by name. The order of the entries is
0066: * undefined.
0067: * <LI>Text - A <CODE>TextMessage</CODE> object's message body contains a
0068: * <CODE>java.lang.String</CODE> object. This message type can be used
0069: * to transport plain-text messages, and XML messages.
0070: * <LI>Object - An <CODE>ObjectMessage</CODE> object's message body contains
0071: * a <CODE>Serializable</CODE> Java object.
0072: * <LI>Bytes - A <CODE>BytesMessage</CODE> object's message body contains a
0073: * stream of uninterpreted bytes. This message type is for
0074: * literally encoding a body to match an existing message format. In
0075: * many cases, it is possible to use one of the other body types,
0076: * which are easier to use. Although the JMS API allows the use of
0077: * message properties with byte messages, they are typically not used,
0078: * since the inclusion of properties may affect the format.
0079: * </UL>
0080: *
0081: * <H4>Message Headers</H4>
0082: *
0083: * <P>The <CODE>JMSCorrelationID</CODE> header field is used for linking one
0084: * message with
0085: * another. It typically links a reply message with its requesting message.
0086: *
0087: * <P><CODE>JMSCorrelationID</CODE> can hold a provider-specific message ID,
0088: * an application-specific <CODE>String</CODE> object, or a provider-native
0089: * <CODE>byte[]</CODE> value.
0090: *
0091: * <H4>Message Properties</H4>
0092: *
0093: * <P>A <CODE>Message</CODE> object contains a built-in facility for supporting
0094: * application-defined property values. In effect, this provides a mechanism
0095: * for adding application-specific header fields to a message.
0096: *
0097: * <P>Properties allow an application, via message selectors, to have a JMS
0098: * provider select, or filter, messages on its behalf using
0099: * application-specific criteria.
0100: *
0101: * <P>Property names must obey the rules for a message selector identifier.
0102: * Property names must not be null, and must not be empty strings. If a property
0103: * name is set and it is either null or an empty string, an
0104: * <CODE>IllegalArgumentException</CODE> must be thrown.
0105: *
0106: * <P>Property values can be <CODE>boolean</CODE>, <CODE>byte</CODE>,
0107: * <CODE>short</CODE>, <CODE>int</CODE>, <CODE>long</CODE>, <CODE>float</CODE>,
0108: * <CODE>double</CODE>, and <CODE>String</CODE>.
0109: *
0110: * <P>Property values are set prior to sending a message. When a client
0111: * receives a message, its properties are in read-only mode. If a
0112: * client attempts to set properties at this point, a
0113: * <CODE>MessageNotWriteableException</CODE> is thrown. If
0114: * <CODE>clearProperties</CODE> is called, the properties can now be both
0115: * read from and written to. Note that header fields are distinct from
0116: * properties. Header fields are never in read-only mode.
0117: *
0118: * <P>A property value may duplicate a value in a message's body, or it may
0119: * not. Although JMS does not define a policy for what should or should not
0120: * be made a property, application developers should note that JMS providers
0121: * will likely handle data in a message's body more efficiently than data in
0122: * a message's properties. For best performance, applications should use
0123: * message properties only when they need to customize a message's header.
0124: * The primary reason for doing this is to support customized message
0125: * selection.
0126: *
0127: * <P>Message properties support the following conversion table. The marked
0128: * cases must be supported. The unmarked cases must throw a
0129: * <CODE>JMSException</CODE>. The <CODE>String</CODE>-to-primitive conversions
0130: * may throw a runtime exception if the
0131: * primitive's <CODE>valueOf</CODE> method does not accept the
0132: * <CODE>String</CODE> as a valid representation of the primitive.
0133: *
0134: * <P>A value written as the row type can be read as the column type.
0135: *
0136: * <PRE>
0137: * | | boolean byte short int long float double String
0138: * |----------------------------------------------------------
0139: * |boolean | X X
0140: * |byte | X X X X X
0141: * |short | X X X X
0142: * |int | X X X
0143: * |long | X X
0144: * |float | X X X
0145: * |double | X X
0146: * |String | X X X X X X X X
0147: * |----------------------------------------------------------
0148: * </PRE>
0149: *
0150: * <P>In addition to the type-specific set/get methods for properties, JMS
0151: * provides the <CODE>setObjectProperty</CODE> and
0152: * <CODE>getObjectProperty</CODE> methods. These support the same set of
0153: * property types using the objectified primitive values. Their purpose is
0154: * to allow the decision of property type to made at execution time rather
0155: * than at compile time. They support the same property value conversions.
0156: *
0157: * <P>The <CODE>setObjectProperty</CODE> method accepts values of class
0158: * <CODE>Boolean</CODE>, <CODE>Byte</CODE>, <CODE>Short</CODE>,
0159: * <CODE>Integer</CODE>, <CODE>Long</CODE>, <CODE>Float</CODE>,
0160: * <CODE>Double</CODE>, and <CODE>String</CODE>. An attempt
0161: * to use any other class must throw a <CODE>JMSException</CODE>.
0162: *
0163: * <P>The <CODE>getObjectProperty</CODE> method only returns values of class
0164: * <CODE>Boolean</CODE>, <CODE>Byte</CODE>, <CODE>Short</CODE>,
0165: * <CODE>Integer</CODE>, <CODE>Long</CODE>, <CODE>Float</CODE>,
0166: * <CODE>Double</CODE>, and <CODE>String</CODE>.
0167: *
0168: * <P>The order of property values is not defined. To iterate through a
0169: * message's property values, use <CODE>getPropertyNames</CODE> to retrieve
0170: * a property name enumeration and then use the various property get methods
0171: * to retrieve their values.
0172: *
0173: * <P>A message's properties are deleted by the <CODE>clearProperties</CODE>
0174: * method. This leaves the message with an empty set of properties.
0175: *
0176: * <P>Getting a property value for a name which has not been set returns a
0177: * null value. Only the <CODE>getStringProperty</CODE> and
0178: * <CODE>getObjectProperty</CODE> methods can return a null value.
0179: * Attempting to read a null value as a primitive type must be treated as
0180: * calling the primitive's corresponding <CODE>valueOf(String)</CODE>
0181: * conversion method with a null value.
0182: *
0183: * <P>The JMS API reserves the <CODE>JMSX</CODE> property name prefix for JMS
0184: * defined properties.
0185: * The full set of these properties is defined in the Java Message Service
0186: * specification. New JMS defined properties may be added in later versions
0187: * of the JMS API. Support for these properties is optional. The
0188: * <CODE>String[] ConnectionMetaData.getJMSXPropertyNames</CODE> method
0189: * returns the names of the JMSX properties supported by a connection.
0190: *
0191: * <P>JMSX properties may be referenced in message selectors whether or not
0192: * they are supported by a connection. If they are not present in a
0193: * message, they are treated like any other absent property.
0194: *
0195: * <P>JMSX properties defined in the specification as "set by provider on
0196: * send" are available to both the producer and the consumers of the message.
0197: * JMSX properties defined in the specification as "set by provider on
0198: * receive" are available only to the consumers.
0199: *
0200: * <P><CODE>JMSXGroupID</CODE> and <CODE>JMSXGroupSeq</CODE> are standard
0201: * properties that clients
0202: * should use if they want to group messages. All providers must support them.
0203: * Unless specifically noted, the values and semantics of the JMSX properties
0204: * are undefined.
0205: *
0206: * <P>The JMS API reserves the <CODE>JMS_<I>vendor_name</I></CODE> property
0207: * name prefix for provider-specific properties. Each provider defines its own
0208: * value for <CODE><I>vendor_name</I></CODE>. This is the mechanism a JMS
0209: * provider uses to make its special per-message services available to a JMS
0210: * client.
0211: *
0212: * <P>The purpose of provider-specific properties is to provide special
0213: * features needed to integrate JMS clients with provider-native clients in a
0214: * single JMS application. They should not be used for messaging between JMS
0215: * clients.
0216: *
0217: * <H4>Provider Implementations of JMS Message Interfaces</H4>
0218: *
0219: * <P>The JMS API provides a set of message interfaces that define the JMS
0220: * message
0221: * model. It does not provide implementations of these interfaces.
0222: *
0223: * <P>Each JMS provider supplies a set of message factories with its
0224: * <CODE>Session</CODE> object for creating instances of messages. This allows
0225: * a provider to use message implementations tailored to its specific needs.
0226: *
0227: * <P>A provider must be prepared to accept message implementations that are
0228: * not its own. They may not be handled as efficiently as its own
0229: * implementation; however, they must be handled.
0230: *
0231: * <P>Note the following exception case when a provider is handling a foreign
0232: * message implementation. If the foreign message implementation contains a
0233: * <CODE>JMSReplyTo</CODE> header field that is set to a foreign destination
0234: * implementation, the provider is not required to handle or preserve the
0235: * value of this header field.
0236: *
0237: * <H4>Message Selectors</H4>
0238: *
0239: * <P>A JMS message selector allows a client to specify, by
0240: * header field references and property references, the
0241: * messages it is interested in. Only messages whose header
0242: * and property values
0243: * match the
0244: * selector are delivered. What it means for a message not to be delivered
0245: * depends on the <CODE>MessageConsumer</CODE> being used (see
0246: * {@link javax.jms.QueueReceiver QueueReceiver} and
0247: * {@link javax.jms.TopicSubscriber TopicSubscriber}).
0248: *
0249: * <P>Message selectors cannot reference message body values.
0250: *
0251: * <P>A message selector matches a message if the selector evaluates to
0252: * true when the message's header field values and property values are
0253: * substituted for their corresponding identifiers in the selector.
0254: *
0255: * <P>A message selector is a <CODE>String</CODE> whose syntax is based on a
0256: * subset of
0257: * the SQL92 conditional expression syntax. If the value of a message selector
0258: * is an empty string, the value is treated as a null and indicates that there
0259: * is no message selector for the message consumer.
0260: *
0261: * <P>The order of evaluation of a message selector is from left to right
0262: * within precedence level. Parentheses can be used to change this order.
0263: *
0264: * <P>Predefined selector literals and operator names are shown here in
0265: * uppercase; however, they are case insensitive.
0266: *
0267: * <P>A selector can contain:
0268: *
0269: * <UL>
0270: * <LI>Literals:
0271: * <UL>
0272: * <LI>A string literal is enclosed in single quotes, with a single quote
0273: * represented by doubled single quote; for example,
0274: * <CODE>'literal'</CODE> and <CODE>'literal''s'</CODE>. Like
0275: * string literals in the Java programming language, these use the
0276: * Unicode character encoding.
0277: * <LI>An exact numeric literal is a numeric value without a decimal
0278: * point, such as <CODE>57</CODE>, <CODE>-957</CODE>, and
0279: * <CODE>+62</CODE>; numbers in the range of <CODE>long</CODE> are
0280: * supported. Exact numeric literals use the integer literal
0281: * syntax of the Java programming language.
0282: * <LI>An approximate numeric literal is a numeric value in scientific
0283: * notation, such as <CODE>7E3</CODE> and <CODE>-57.9E2</CODE>, or a
0284: * numeric value with a decimal, such as <CODE>7.</CODE>,
0285: * <CODE>-95.7</CODE>, and <CODE>+6.2</CODE>; numbers in the range of
0286: * <CODE>double</CODE> are supported. Approximate literals use the
0287: * floating-point literal syntax of the Java programming language.
0288: * <LI>The boolean literals <CODE>TRUE</CODE> and <CODE>FALSE</CODE>.
0289: * </UL>
0290: * <LI>Identifiers:
0291: * <UL>
0292: * <LI>An identifier is an unlimited-length sequence of letters
0293: * and digits, the first of which must be a letter. A letter is any
0294: * character for which the method <CODE>Character.isJavaLetter</CODE>
0295: * returns true. This includes <CODE>'_'</CODE> and <CODE>'$'</CODE>.
0296: * A letter or digit is any character for which the method
0297: * <CODE>Character.isJavaLetterOrDigit</CODE> returns true.
0298: * <LI>Identifiers cannot be the names <CODE>NULL</CODE>,
0299: * <CODE>TRUE</CODE>, and <CODE>FALSE</CODE>.
0300: * <LI>Identifiers cannot be <CODE>NOT</CODE>, <CODE>AND</CODE>,
0301: * <CODE>OR</CODE>, <CODE>BETWEEN</CODE>, <CODE>LIKE</CODE>,
0302: * <CODE>IN</CODE>, <CODE>IS</CODE>, or <CODE>ESCAPE</CODE>.
0303: * <LI>Identifiers are either header field references or property
0304: * references. The type of a property value in a message selector
0305: * corresponds to the type used to set the property. If a property
0306: * that does not exist in a message is referenced, its value is
0307: * <CODE>NULL</CODE>.
0308: * <LI>The conversions that apply to the get methods for properties do not
0309: * apply when a property is used in a message selector expression.
0310: * For example, suppose you set a property as a string value, as in the
0311: * following:
0312: * <PRE>myMessage.setStringProperty("NumberOfOrders", "2");</PRE>
0313: * The following expression in a message selector would evaluate to
0314: * false, because a string cannot be used in an arithmetic expression:
0315: * <PRE>"NumberOfOrders > 1"</PRE>
0316: * <LI>Identifiers are case-sensitive.
0317: * <LI>Message header field references are restricted to
0318: * <CODE>JMSDeliveryMode</CODE>, <CODE>JMSPriority</CODE>,
0319: * <CODE>JMSMessageID</CODE>, <CODE>JMSTimestamp</CODE>,
0320: * <CODE>JMSCorrelationID</CODE>, and <CODE>JMSType</CODE>.
0321: * <CODE>JMSMessageID</CODE>, <CODE>JMSCorrelationID</CODE>, and
0322: * <CODE>JMSType</CODE> values may be null and if so are treated as a
0323: * <CODE>NULL</CODE> value.
0324: * <LI>Any name beginning with <CODE>'JMSX'</CODE> is a JMS defined
0325: * property name.
0326: * <LI>Any name beginning with <CODE>'JMS_'</CODE> is a provider-specific
0327: * property name.
0328: * <LI>Any name that does not begin with <CODE>'JMS'</CODE> is an
0329: * application-specific property name.
0330: * </UL>
0331: * <LI>White space is the same as that defined for the Java programming
0332: * language: space, horizontal tab, form feed, and line terminator.
0333: * <LI>Expressions:
0334: * <UL>
0335: * <LI>A selector is a conditional expression; a selector that evaluates
0336: * to <CODE>true</CODE> matches; a selector that evaluates to
0337: * <CODE>false</CODE> or unknown does not match.
0338: * <LI>Arithmetic expressions are composed of themselves, arithmetic
0339: * operations, identifiers (whose value is treated as a numeric
0340: * literal), and numeric literals.
0341: * <LI>Conditional expressions are composed of themselves, comparison
0342: * operations, and logical operations.
0343: * </UL>
0344: * <LI>Standard bracketing <CODE>()</CODE> for ordering expression evaluation
0345: * is supported.
0346: * <LI>Logical operators in precedence order: <CODE>NOT</CODE>,
0347: * <CODE>AND</CODE>, <CODE>OR</CODE>
0348: * <LI>Comparison operators: <CODE>=</CODE>, <CODE>></CODE>, <CODE>>=</CODE>,
0349: * <CODE><</CODE>, <CODE><=</CODE>, <CODE><></CODE> (not equal)
0350: * <UL>
0351: * <LI>Only like type values can be compared. One exception is that it
0352: * is valid to compare exact numeric values and approximate numeric
0353: * values; the type conversion required is defined by the rules of
0354: * numeric promotion in the Java programming language. If the
0355: * comparison of non-like type values is attempted, the value of the
0356: * operation is false. If either of the type values evaluates to
0357: * <CODE>NULL</CODE>, the value of the expression is unknown.
0358: * <LI>String and boolean comparison is restricted to <CODE>=</CODE> and
0359: * <CODE><></CODE>. Two strings are equal
0360: * if and only if they contain the same sequence of characters.
0361: * </UL>
0362: * <LI>Arithmetic operators in precedence order:
0363: * <UL>
0364: * <LI><CODE>+</CODE>, <CODE>-</CODE> (unary)
0365: * <LI><CODE>*</CODE>, <CODE>/</CODE> (multiplication and division)
0366: * <LI><CODE>+</CODE>, <CODE>-</CODE> (addition and subtraction)
0367: * <LI>Arithmetic operations must use numeric promotion in the Java
0368: * programming language.
0369: * </UL>
0370: * <LI><CODE><I>arithmetic-expr1</I> [NOT] BETWEEN <I>arithmetic-expr2</I>
0371: * AND <I>arithmetic-expr3</I></CODE> (comparison operator)
0372: * <UL>
0373: * <LI><CODE>"age BETWEEN 15 AND 19"</CODE> is
0374: * equivalent to
0375: * <CODE>"age >= 15 AND age <= 19"</CODE>
0376: * <LI><CODE>"age NOT BETWEEN 15 AND 19"</CODE>
0377: * is equivalent to
0378: * <CODE>"age < 15 OR age > 19"</CODE>
0379: * </UL>
0380: * <LI><CODE><I>identifier</I> [NOT] IN (<I>string-literal1</I>,
0381: * <I>string-literal2</I>,...)</CODE> (comparison operator where
0382: * <CODE><I>identifier</I></CODE> has a <CODE>String</CODE> or
0383: * <CODE>NULL</CODE> value)
0384: * <UL>
0385: * <LI><CODE>"Country IN (' UK', 'US', 'France')"</CODE>
0386: * is true for
0387: * <CODE>'UK'</CODE> and false for <CODE>'Peru'</CODE>; it is
0388: * equivalent to the expression
0389: * <CODE>"(Country = ' UK') OR (Country = ' US') OR (Country = ' France')"</CODE>
0390: * <LI><CODE>"Country NOT IN (' UK', 'US', 'France')"</CODE>
0391: * is false for <CODE>'UK'</CODE> and true for <CODE>'Peru'</CODE>; it
0392: * is equivalent to the expression
0393: * <CODE>"NOT ((Country = ' UK') OR (Country = ' US') OR (Country = ' France'))"</CODE>
0394: * <LI>If identifier of an <CODE>IN</CODE> or <CODE>NOT IN</CODE>
0395: * operation is <CODE>NULL</CODE>, the value of the operation is
0396: * unknown.
0397: * </UL>
0398: * <LI><CODE><I>identifier</I> [NOT] LIKE <I>pattern-value</I> [ESCAPE
0399: * <I>escape-character</I>]</CODE> (comparison operator, where
0400: * <CODE><I>identifier</I></CODE> has a <CODE>String</CODE> value;
0401: * <CODE><I>pattern-value</I></CODE> is a string literal where
0402: * <CODE>'_'</CODE> stands for any single character; <CODE>'%'</CODE>
0403: * stands for any sequence of characters, including the empty sequence;
0404: * and all other characters stand for themselves. The optional
0405: * <CODE><I>escape-character</I></CODE> is a single-character string
0406: * literal whose character is used to escape the special meaning of the
0407: * <CODE>'_'</CODE> and <CODE>'%'</CODE> in
0408: * <CODE><I>pattern-value</I></CODE>.)
0409: * <UL>
0410: * <LI><CODE>"phone LIKE '12%3'"</CODE> is true for
0411: * <CODE>'123'</CODE> or <CODE>'12993'</CODE> and false for
0412: * <CODE>'1234'</CODE>
0413: * <LI><CODE>"word LIKE 'l_se'"</CODE> is true for
0414: * <CODE>'lose'</CODE> and false for <CODE>'loose'</CODE>
0415: * <LI><CODE>"underscored LIKE '\_%' ESCAPE '\'"</CODE>
0416: * is true for <CODE>'_foo'</CODE> and false for <CODE>'bar'</CODE>
0417: * <LI><CODE>"phone NOT LIKE '12%3'"</CODE> is false for
0418: * <CODE>'123'</CODE> or <CODE>'12993'</CODE> and true for
0419: * <CODE>'1234'</CODE>
0420: * <LI>If <CODE><I>identifier</I></CODE> of a <CODE>LIKE</CODE> or
0421: * <CODE>NOT LIKE</CODE> operation is <CODE>NULL</CODE>, the value
0422: * of the operation is unknown.
0423: * </UL>
0424: * <LI><CODE><I>identifier</I> IS NULL</CODE> (comparison operator that tests
0425: * for a null header field value or a missing property value)
0426: * <UL>
0427: * <LI><CODE>"prop_name IS NULL"</CODE>
0428: * </UL>
0429: * <LI><CODE><I>identifier</I> IS NOT NULL</CODE> (comparison operator that
0430: * tests for the existence of a non-null header field value or a property
0431: * value)
0432: * <UL>
0433: * <LI><CODE>"prop_name IS NOT NULL"</CODE>
0434: * </UL>
0435: *
0436: * <P>JMS providers are required to verify the syntactic correctness of a
0437: * message selector at the time it is presented. A method that provides a
0438: * syntactically incorrect selector must result in a <CODE>JMSException</CODE>.
0439: * JMS providers may also optionally provide some semantic checking at the time
0440: * the selector is presented. Not all semantic checking can be performed at
0441: * the time a message selector is presented, because property types are not known.
0442: *
0443: * <P>The following message selector selects messages with a message type
0444: * of car and color of blue and weight greater than 2500 pounds:
0445: *
0446: * <PRE>"JMSType = 'car' AND color = 'blue' AND weight > 2500"</PRE>
0447: *
0448: * <H4>Null Values</H4>
0449: *
0450: * <P>As noted above, property values may be <CODE>NULL</CODE>. The evaluation
0451: * of selector expressions containing <CODE>NULL</CODE> values is defined by
0452: * SQL92 <CODE>NULL</CODE> semantics. A brief description of these semantics
0453: * is provided here.
0454: *
0455: * <P>SQL treats a <CODE>NULL</CODE> value as unknown. Comparison or arithmetic
0456: * with an unknown value always yields an unknown value.
0457: *
0458: * <P>The <CODE>IS NULL</CODE> and <CODE>IS NOT NULL</CODE> operators convert
0459: * an unknown value into the respective <CODE>TRUE</CODE> and
0460: * <CODE>FALSE</CODE> values.
0461: *
0462: * <P>The boolean operators use three-valued logic as defined by the
0463: * following tables:
0464: *
0465: * <P><B>The definition of the <CODE>AND</CODE> operator</B>
0466: *
0467: * <PRE>
0468: * | AND | T | F | U
0469: * +------+-------+-------+-------
0470: * | T | T | F | U
0471: * | F | F | F | F
0472: * | U | U | F | U
0473: * +------+-------+-------+-------
0474: * </PRE>
0475: *
0476: * <P><B>The definition of the <CODE>OR</CODE> operator</B>
0477: *
0478: * <PRE>
0479: * | OR | T | F | U
0480: * +------+-------+-------+--------
0481: * | T | T | T | T
0482: * | F | T | F | U
0483: * | U | T | U | U
0484: * +------+-------+-------+-------
0485: * </PRE>
0486: *
0487: * <P><B>The definition of the <CODE>NOT</CODE> operator</B>
0488: *
0489: * <PRE>
0490: * | NOT
0491: * +------+------
0492: * | T | F
0493: * | F | T
0494: * | U | U
0495: * +------+-------
0496: * </PRE>
0497: *
0498: * <H4>Special Notes</H4>
0499: *
0500: * <P>When used in a message selector, the <CODE>JMSDeliveryMode</CODE> header
0501: * field is treated as having the values <CODE>'PERSISTENT'</CODE> and
0502: * <CODE>'NON_PERSISTENT'</CODE>.
0503: *
0504: * <P>Date and time values should use the standard <CODE>long</CODE>
0505: * millisecond value. When a date or time literal is included in a message
0506: * selector, it should be an integer literal for a millisecond value. The
0507: * standard way to produce millisecond values is to use
0508: * <CODE>java.util.Calendar</CODE>.
0509: *
0510: * <P>Although SQL supports fixed decimal comparison and arithmetic, JMS
0511: * message selectors do not. This is the reason for restricting exact
0512: * numeric literals to those without a decimal (and the addition of
0513: * numerics with a decimal as an alternate representation for
0514: * approximate numeric values).
0515: *
0516: * <P>SQL comments are not supported.
0517: *
0518: * @version 1.1 April 2, 2002
0519: * @author Mark Hapner
0520: * @author Rich Burridge
0521: * @author Kate Stout
0522: *
0523: * @see javax.jms.MessageConsumer#receive()
0524: * @see javax.jms.MessageConsumer#receive(long)
0525: * @see javax.jms.MessageConsumer#receiveNoWait()
0526: * @see javax.jms.MessageListener#onMessage(Message)
0527: * @see javax.jms.BytesMessage
0528: * @see javax.jms.MapMessage
0529: * @see javax.jms.ObjectMessage
0530: * @see javax.jms.StreamMessage
0531: * @see javax.jms.TextMessage
0532: */
0533:
0534: public interface Message {
0535:
0536: /** The message producer's default delivery mode is <CODE>PERSISTENT</CODE>.
0537: *
0538: * @see DeliveryMode#PERSISTENT
0539: */
0540: static final int DEFAULT_DELIVERY_MODE = DeliveryMode.PERSISTENT;
0541:
0542: /** The message producer's default priority is 4.
0543: */
0544: static final int DEFAULT_PRIORITY = 4;
0545:
0546: /** The message producer's default time to live is unlimited; the message
0547: * never expires.
0548: */
0549: static final long DEFAULT_TIME_TO_LIVE = 0;
0550:
0551: /** Gets the message ID.
0552: *
0553: * <P>The <CODE>JMSMessageID</CODE> header field contains a value that
0554: * uniquely identifies each message sent by a provider.
0555: *
0556: * <P>When a message is sent, <CODE>JMSMessageID</CODE> can be ignored.
0557: * When the <CODE>send</CODE> or <CODE>publish</CODE> method returns, it
0558: * contains a provider-assigned value.
0559: *
0560: * <P>A <CODE>JMSMessageID</CODE> is a <CODE>String</CODE> value that
0561: * should function as a
0562: * unique key for identifying messages in a historical repository.
0563: * The exact scope of uniqueness is provider-defined. It should at
0564: * least cover all messages for a specific installation of a
0565: * provider, where an installation is some connected set of message
0566: * routers.
0567: *
0568: * <P>All <CODE>JMSMessageID</CODE> values must start with the prefix
0569: * <CODE>'ID:'</CODE>.
0570: * Uniqueness of message ID values across different providers is
0571: * not required.
0572: *
0573: * <P>Since message IDs take some effort to create and increase a
0574: * message's size, some JMS providers may be able to optimize message
0575: * overhead if they are given a hint that the message ID is not used by
0576: * an application. By calling the
0577: * <CODE>MessageProducer.setDisableMessageID</CODE> method, a JMS client
0578: * enables this potential optimization for all messages sent by that
0579: * message producer. If the JMS provider accepts this
0580: * hint, these messages must have the message ID set to null; if the
0581: * provider ignores the hint, the message ID must be set to its normal
0582: * unique value.
0583: *
0584: * @return the message ID
0585: *
0586: * @exception JMSException if the JMS provider fails to get the message ID
0587: * due to some internal error.
0588: * @see javax.jms.Message#setJMSMessageID(String)
0589: * @see javax.jms.MessageProducer#setDisableMessageID(boolean)
0590: */
0591:
0592: String getJMSMessageID() throws JMSException;
0593:
0594: /** Sets the message ID.
0595: *
0596: * <P>JMS providers set this field when a message is sent. This method
0597: * can be used to change the value for a message that has been received.
0598: *
0599: * @param id the ID of the message
0600: *
0601: * @exception JMSException if the JMS provider fails to set the message ID
0602: * due to some internal error.
0603: *
0604: * @see javax.jms.Message#getJMSMessageID()
0605: */
0606:
0607: void setJMSMessageID(String id) throws JMSException;
0608:
0609: /** Gets the message timestamp.
0610: *
0611: * <P>The <CODE>JMSTimestamp</CODE> header field contains the time a
0612: * message was
0613: * handed off to a provider to be sent. It is not the time the
0614: * message was actually transmitted, because the actual send may occur
0615: * later due to transactions or other client-side queueing of messages.
0616: *
0617: * <P>When a message is sent, <CODE>JMSTimestamp</CODE> is ignored. When
0618: * the <CODE>send</CODE> or <CODE>publish</CODE>
0619: * method returns, it contains a time value somewhere in the interval
0620: * between the call and the return. The value is in the format of a normal
0621: * millis time value in the Java programming language.
0622: *
0623: * <P>Since timestamps take some effort to create and increase a
0624: * message's size, some JMS providers may be able to optimize message
0625: * overhead if they are given a hint that the timestamp is not used by an
0626: * application. By calling the
0627: * <CODE>MessageProducer.setDisableMessageTimestamp</CODE> method, a JMS
0628: * client enables this potential optimization for all messages sent by
0629: * that message producer. If the JMS provider accepts this
0630: * hint, these messages must have the timestamp set to zero; if the
0631: * provider ignores the hint, the timestamp must be set to its normal
0632: * value.
0633: *
0634: * @return the message timestamp
0635: *
0636: * @exception JMSException if the JMS provider fails to get the timestamp
0637: * due to some internal error.
0638: *
0639: * @see javax.jms.Message#setJMSTimestamp(long)
0640: * @see javax.jms.MessageProducer#setDisableMessageTimestamp(boolean)
0641: */
0642:
0643: long getJMSTimestamp() throws JMSException;
0644:
0645: /** Sets the message timestamp.
0646: *
0647: * <P>JMS providers set this field when a message is sent. This method
0648: * can be used to change the value for a message that has been received.
0649: *
0650: * @param timestamp the timestamp for this message
0651: *
0652: * @exception JMSException if the JMS provider fails to set the timestamp
0653: * due to some internal error.
0654: *
0655: * @see javax.jms.Message#getJMSTimestamp()
0656: */
0657:
0658: void setJMSTimestamp(long timestamp) throws JMSException;
0659:
0660: /** Gets the correlation ID as an array of bytes for the message.
0661: *
0662: * <P>The use of a <CODE>byte[]</CODE> value for
0663: * <CODE>JMSCorrelationID</CODE> is non-portable.
0664: *
0665: * @return the correlation ID of a message as an array of bytes
0666: *
0667: * @exception JMSException if the JMS provider fails to get the correlation
0668: * ID due to some internal error.
0669: *
0670: * @see javax.jms.Message#setJMSCorrelationID(String)
0671: * @see javax.jms.Message#getJMSCorrelationID()
0672: * @see javax.jms.Message#setJMSCorrelationIDAsBytes(byte[])
0673: */
0674:
0675: byte[] getJMSCorrelationIDAsBytes() throws JMSException;
0676:
0677: /** Sets the correlation ID as an array of bytes for the message.
0678: *
0679: * <P>The array is copied before the method returns, so
0680: * future modifications to the array will not alter this message header.
0681: *
0682: * <P>If a provider supports the native concept of correlation ID, a
0683: * JMS client may need to assign specific <CODE>JMSCorrelationID</CODE>
0684: * values to match those expected by native messaging clients.
0685: * JMS providers without native correlation ID values are not required to
0686: * support this method and its corresponding get method; their
0687: * implementation may throw a
0688: * <CODE>java.lang.UnsupportedOperationException</CODE>.
0689: *
0690: * <P>The use of a <CODE>byte[]</CODE> value for
0691: * <CODE>JMSCorrelationID</CODE> is non-portable.
0692: *
0693: * @param correlationID the correlation ID value as an array of bytes
0694: *
0695: * @exception JMSException if the JMS provider fails to set the correlation
0696: * ID due to some internal error.
0697: *
0698: * @see javax.jms.Message#setJMSCorrelationID(String)
0699: * @see javax.jms.Message#getJMSCorrelationID()
0700: * @see javax.jms.Message#getJMSCorrelationIDAsBytes()
0701: */
0702:
0703: void setJMSCorrelationIDAsBytes(byte[] correlationID)
0704: throws JMSException;
0705:
0706: /** Sets the correlation ID for the message.
0707: *
0708: * <P>A client can use the <CODE>JMSCorrelationID</CODE> header field to
0709: * link one message with another. A typical use is to link a response
0710: * message with its request message.
0711: *
0712: * <P><CODE>JMSCorrelationID</CODE> can hold one of the following:
0713: * <UL>
0714: * <LI>A provider-specific message ID
0715: * <LI>An application-specific <CODE>String</CODE>
0716: * <LI>A provider-native <CODE>byte[]</CODE> value
0717: * </UL>
0718: *
0719: * <P>Since each message sent by a JMS provider is assigned a message ID
0720: * value, it is convenient to link messages via message ID. All message ID
0721: * values must start with the <CODE>'ID:'</CODE> prefix.
0722: *
0723: * <P>In some cases, an application (made up of several clients) needs to
0724: * use an application-specific value for linking messages. For instance,
0725: * an application may use <CODE>JMSCorrelationID</CODE> to hold a value
0726: * referencing some external information. Application-specified values
0727: * must not start with the <CODE>'ID:'</CODE> prefix; this is reserved for
0728: * provider-generated message ID values.
0729: *
0730: * <P>If a provider supports the native concept of correlation ID, a JMS
0731: * client may need to assign specific <CODE>JMSCorrelationID</CODE> values
0732: * to match those expected by clients that do not use the JMS API. A
0733: * <CODE>byte[]</CODE> value is used for this
0734: * purpose. JMS providers without native correlation ID values are not
0735: * required to support <CODE>byte[]</CODE> values. The use of a
0736: * <CODE>byte[]</CODE> value for <CODE>JMSCorrelationID</CODE> is
0737: * non-portable.
0738: *
0739: * @param correlationID the message ID of a message being referred to
0740: *
0741: * @exception JMSException if the JMS provider fails to set the correlation
0742: * ID due to some internal error.
0743: *
0744: * @see javax.jms.Message#getJMSCorrelationID()
0745: * @see javax.jms.Message#getJMSCorrelationIDAsBytes()
0746: * @see javax.jms.Message#setJMSCorrelationIDAsBytes(byte[])
0747: */
0748:
0749: void setJMSCorrelationID(String correlationID) throws JMSException;
0750:
0751: /** Gets the correlation ID for the message.
0752: *
0753: * <P>This method is used to return correlation ID values that are
0754: * either provider-specific message IDs or application-specific
0755: * <CODE>String</CODE> values.
0756: *
0757: * @return the correlation ID of a message as a <CODE>String</CODE>
0758: *
0759: * @exception JMSException if the JMS provider fails to get the correlation
0760: * ID due to some internal error.
0761: *
0762: * @see javax.jms.Message#setJMSCorrelationID(String)
0763: * @see javax.jms.Message#getJMSCorrelationIDAsBytes()
0764: * @see javax.jms.Message#setJMSCorrelationIDAsBytes(byte[])
0765: */
0766:
0767: String getJMSCorrelationID() throws JMSException;
0768:
0769: /** Gets the <CODE>Destination</CODE> object to which a reply to this
0770: * message should be sent.
0771: *
0772: * @return <CODE>Destination</CODE> to which to send a response to this
0773: * message
0774: *
0775: * @exception JMSException if the JMS provider fails to get the
0776: * <CODE>JMSReplyTo</CODE> destination due to some
0777: * internal error.
0778: *
0779: * @see javax.jms.Message#setJMSReplyTo(Destination)
0780: */
0781:
0782: Destination getJMSReplyTo() throws JMSException;
0783:
0784: /** Sets the <CODE>Destination</CODE> object to which a reply to this
0785: * message should be sent.
0786: *
0787: * <P>The <CODE>JMSReplyTo</CODE> header field contains the destination
0788: * where a reply
0789: * to the current message should be sent. If it is null, no reply is
0790: * expected. The destination may be either a <CODE>Queue</CODE> object or
0791: * a <CODE>Topic</CODE> object.
0792: *
0793: * <P>Messages sent with a null <CODE>JMSReplyTo</CODE> value may be a
0794: * notification of some event, or they may just be some data the sender
0795: * thinks is of interest.
0796: *
0797: * <P>Messages with a <CODE>JMSReplyTo</CODE> value typically expect a
0798: * response. A response is optional; it is up to the client to decide.
0799: * These messages are called requests. A message sent in response to a
0800: * request is called a reply.
0801: *
0802: * <P>In some cases a client may wish to match a request it sent earlier
0803: * with a reply it has just received. The client can use the
0804: * <CODE>JMSCorrelationID</CODE> header field for this purpose.
0805: *
0806: * @param replyTo <CODE>Destination</CODE> to which to send a response to
0807: * this message
0808: *
0809: * @exception JMSException if the JMS provider fails to set the
0810: * <CODE>JMSReplyTo</CODE> destination due to some
0811: * internal error.
0812: *
0813: * @see javax.jms.Message#getJMSReplyTo()
0814: */
0815:
0816: void setJMSReplyTo(Destination replyTo) throws JMSException;
0817:
0818: /** Gets the <CODE>Destination</CODE> object for this message.
0819: *
0820: * <P>The <CODE>JMSDestination</CODE> header field contains the
0821: * destination to which the message is being sent.
0822: *
0823: * <P>When a message is sent, this field is ignored. After completion
0824: * of the <CODE>send</CODE> or <CODE>publish</CODE> method, the field
0825: * holds the destination specified by the method.
0826: *
0827: * <P>When a message is received, its <CODE>JMSDestination</CODE> value
0828: * must be equivalent to the value assigned when it was sent.
0829: *
0830: * @return the destination of this message
0831: *
0832: * @exception JMSException if the JMS provider fails to get the destination
0833: * due to some internal error.
0834: *
0835: * @see javax.jms.Message#setJMSDestination(Destination)
0836: */
0837:
0838: Destination getJMSDestination() throws JMSException;
0839:
0840: /** Sets the <CODE>Destination</CODE> object for this message.
0841: *
0842: * <P>JMS providers set this field when a message is sent. This method
0843: * can be used to change the value for a message that has been received.
0844: *
0845: * @param destination the destination for this message
0846: *
0847: * @exception JMSException if the JMS provider fails to set the destination
0848: * due to some internal error.
0849: *
0850: * @see javax.jms.Message#getJMSDestination()
0851: */
0852:
0853: void setJMSDestination(Destination destination) throws JMSException;
0854:
0855: /** Gets the <CODE>DeliveryMode</CODE> value specified for this message.
0856: *
0857: * @return the delivery mode for this message
0858: *
0859: * @exception JMSException if the JMS provider fails to get the
0860: * delivery mode due to some internal error.
0861: *
0862: * @see javax.jms.Message#setJMSDeliveryMode(int)
0863: * @see javax.jms.DeliveryMode
0864: */
0865:
0866: int getJMSDeliveryMode() throws JMSException;
0867:
0868: /** Sets the <CODE>DeliveryMode</CODE> value for this message.
0869: *
0870: * <P>JMS providers set this field when a message is sent. This method
0871: * can be used to change the value for a message that has been received.
0872: *
0873: * @param deliveryMode the delivery mode for this message
0874: *
0875: * @exception JMSException if the JMS provider fails to set the
0876: * delivery mode due to some internal error.
0877: *
0878: * @see javax.jms.Message#getJMSDeliveryMode()
0879: * @see javax.jms.DeliveryMode
0880: */
0881:
0882: void setJMSDeliveryMode(int deliveryMode) throws JMSException;
0883:
0884: /** Gets an indication of whether this message is being redelivered.
0885: *
0886: * <P>If a client receives a message with the <CODE>JMSRedelivered</CODE>
0887: * field set,
0888: * it is likely, but not guaranteed, that this message was delivered
0889: * earlier but that its receipt was not acknowledged
0890: * at that time.
0891: *
0892: * @return true if this message is being redelivered
0893: *
0894: * @exception JMSException if the JMS provider fails to get the redelivered
0895: * state due to some internal error.
0896: *
0897: * @see javax.jms.Message#setJMSRedelivered(boolean)
0898: */
0899:
0900: boolean getJMSRedelivered() throws JMSException;
0901:
0902: /** Specifies whether this message is being redelivered.
0903: *
0904: * <P>This field is set at the time the message is delivered. This
0905: * method can be used to change the value for a message that has
0906: * been received.
0907: *
0908: * @param redelivered an indication of whether this message is being
0909: * redelivered
0910: *
0911: * @exception JMSException if the JMS provider fails to set the redelivered
0912: * state due to some internal error.
0913: *
0914: * @see javax.jms.Message#getJMSRedelivered()
0915: */
0916:
0917: void setJMSRedelivered(boolean redelivered) throws JMSException;
0918:
0919: /** Gets the message type identifier supplied by the client when the
0920: * message was sent.
0921: *
0922: * @return the message type
0923: *
0924: * @exception JMSException if the JMS provider fails to get the message
0925: * type due to some internal error.
0926: *
0927: * @see javax.jms.Message#setJMSType(String)
0928: */
0929:
0930: String getJMSType() throws JMSException;
0931:
0932: /** Sets the message type.
0933: *
0934: * <P>Some JMS providers use a message repository that contains the
0935: * definitions of messages sent by applications. The <CODE>JMSType</CODE>
0936: * header field may reference a message's definition in the provider's
0937: * repository.
0938: *
0939: * <P>The JMS API does not define a standard message definition repository,
0940: * nor does it define a naming policy for the definitions it contains.
0941: *
0942: * <P>Some messaging systems require that a message type definition for
0943: * each application message be created and that each message specify its
0944: * type. In order to work with such JMS providers, JMS clients should
0945: * assign a value to <CODE>JMSType</CODE>, whether the application makes
0946: * use of it or not. This ensures that the field is properly set for those
0947: * providers that require it.
0948: *
0949: * <P>To ensure portability, JMS clients should use symbolic values for
0950: * <CODE>JMSType</CODE> that can be configured at installation time to the
0951: * values defined in the current provider's message repository. If string
0952: * literals are used, they may not be valid type names for some JMS
0953: * providers.
0954: *
0955: * @param type the message type
0956: *
0957: * @exception JMSException if the JMS provider fails to set the message
0958: * type due to some internal error.
0959: *
0960: * @see javax.jms.Message#getJMSType()
0961: */
0962:
0963: void setJMSType(String type) throws JMSException;
0964:
0965: /** Gets the message's expiration value.
0966: *
0967: * <P>When a message is sent, the <CODE>JMSExpiration</CODE> header field
0968: * is left unassigned. After completion of the <CODE>send</CODE> or
0969: * <CODE>publish</CODE> method, it holds the expiration time of the
0970: * message. This is the sum of the time-to-live value specified by the
0971: * client and the GMT at the time of the <CODE>send</CODE> or
0972: * <CODE>publish</CODE>.
0973: *
0974: * <P>If the time-to-live is specified as zero, <CODE>JMSExpiration</CODE>
0975: * is set to zero to indicate that the message does not expire.
0976: *
0977: * <P>When a message's expiration time is reached, a provider should
0978: * discard it. The JMS API does not define any form of notification of
0979: * message expiration.
0980: *
0981: * <P>Clients should not receive messages that have expired; however,
0982: * the JMS API does not guarantee that this will not happen.
0983: *
0984: * @return the time the message expires, which is the sum of the
0985: * time-to-live value specified by the client and the GMT at the
0986: * time of the send
0987: *
0988: * @exception JMSException if the JMS provider fails to get the message
0989: * expiration due to some internal error.
0990: *
0991: * @see javax.jms.Message#setJMSExpiration(long)
0992: */
0993:
0994: long getJMSExpiration() throws JMSException;
0995:
0996: /** Sets the message's expiration value.
0997: *
0998: * <P>JMS providers set this field when a message is sent. This method
0999: * can be used to change the value for a message that has been received.
1000: *
1001: * @param expiration the message's expiration time
1002: *
1003: * @exception JMSException if the JMS provider fails to set the message
1004: * expiration due to some internal error.
1005: *
1006: * @see javax.jms.Message#getJMSExpiration()
1007: */
1008:
1009: void setJMSExpiration(long expiration) throws JMSException;
1010:
1011: /** Gets the message priority level.
1012: *
1013: * <P>The JMS API defines ten levels of priority value, with 0 as the
1014: * lowest
1015: * priority and 9 as the highest. In addition, clients should consider
1016: * priorities 0-4 as gradations of normal priority and priorities 5-9
1017: * as gradations of expedited priority.
1018: *
1019: * <P>The JMS API does not require that a provider strictly implement
1020: * priority
1021: * ordering of messages; however, it should do its best to deliver
1022: * expedited messages ahead of normal messages.
1023: *
1024: * @return the default message priority
1025: *
1026: * @exception JMSException if the JMS provider fails to get the message
1027: * priority due to some internal error.
1028: *
1029: * @see javax.jms.Message#setJMSPriority(int)
1030: */
1031:
1032: int getJMSPriority() throws JMSException;
1033:
1034: /** Sets the priority level for this message.
1035: *
1036: * <P>JMS providers set this field when a message is sent. This method
1037: * can be used to change the value for a message that has been received.
1038: *
1039: * @param priority the priority of this message
1040: *
1041: * @exception JMSException if the JMS provider fails to set the message
1042: * priority due to some internal error.
1043: *
1044: * @see javax.jms.Message#getJMSPriority()
1045: */
1046:
1047: void setJMSPriority(int priority) throws JMSException;
1048:
1049: /** Clears a message's properties.
1050: *
1051: * <P>The message's header fields and body are not cleared.
1052: *
1053: * @exception JMSException if the JMS provider fails to clear the message
1054: * properties due to some internal error.
1055: */
1056:
1057: void clearProperties() throws JMSException;
1058:
1059: /** Indicates whether a property value exists.
1060: *
1061: * @param name the name of the property to test
1062: *
1063: * @return true if the property exists
1064: *
1065: * @exception JMSException if the JMS provider fails to determine if the
1066: * property exists due to some internal error.
1067: */
1068:
1069: boolean propertyExists(String name) throws JMSException;
1070:
1071: /** Returns the value of the <CODE>boolean</CODE> property with the
1072: * specified name.
1073: *
1074: * @param name the name of the <CODE>boolean</CODE> property
1075: *
1076: * @return the <CODE>boolean</CODE> property value for the specified name
1077: *
1078: * @exception JMSException if the JMS provider fails to get the property
1079: * value due to some internal error.
1080: * @exception MessageFormatException if this type conversion is invalid.
1081: */
1082:
1083: boolean getBooleanProperty(String name) throws JMSException;
1084:
1085: /** Returns the value of the <CODE>byte</CODE> property with the specified
1086: * name.
1087: *
1088: * @param name the name of the <CODE>byte</CODE> property
1089: *
1090: * @return the <CODE>byte</CODE> property value for the specified name
1091: *
1092: * @exception JMSException if the JMS provider fails to get the property
1093: * value due to some internal error.
1094: * @exception MessageFormatException if this type conversion is invalid.
1095: */
1096:
1097: byte getByteProperty(String name) throws JMSException;
1098:
1099: /** Returns the value of the <CODE>short</CODE> property with the specified
1100: * name.
1101: *
1102: * @param name the name of the <CODE>short</CODE> property
1103: *
1104: * @return the <CODE>short</CODE> property value for the specified name
1105: *
1106: * @exception JMSException if the JMS provider fails to get the property
1107: * value due to some internal error.
1108: * @exception MessageFormatException if this type conversion is invalid.
1109: */
1110:
1111: short getShortProperty(String name) throws JMSException;
1112:
1113: /** Returns the value of the <CODE>int</CODE> property with the specified
1114: * name.
1115: *
1116: * @param name the name of the <CODE>int</CODE> property
1117: *
1118: * @return the <CODE>int</CODE> property value for the specified name
1119: *
1120: * @exception JMSException if the JMS provider fails to get the property
1121: * value due to some internal error.
1122: * @exception MessageFormatException if this type conversion is invalid.
1123: */
1124:
1125: int getIntProperty(String name) throws JMSException;
1126:
1127: /** Returns the value of the <CODE>long</CODE> property with the specified
1128: * name.
1129: *
1130: * @param name the name of the <CODE>long</CODE> property
1131: *
1132: * @return the <CODE>long</CODE> property value for the specified name
1133: *
1134: * @exception JMSException if the JMS provider fails to get the property
1135: * value due to some internal error.
1136: * @exception MessageFormatException if this type conversion is invalid.
1137: */
1138:
1139: long getLongProperty(String name) throws JMSException;
1140:
1141: /** Returns the value of the <CODE>float</CODE> property with the specified
1142: * name.
1143: *
1144: * @param name the name of the <CODE>float</CODE> property
1145: *
1146: * @return the <CODE>float</CODE> property value for the specified name
1147: *
1148: * @exception JMSException if the JMS provider fails to get the property
1149: * value due to some internal error.
1150: * @exception MessageFormatException if this type conversion is invalid.
1151: */
1152:
1153: float getFloatProperty(String name) throws JMSException;
1154:
1155: /** Returns the value of the <CODE>double</CODE> property with the specified
1156: * name.
1157: *
1158: * @param name the name of the <CODE>double</CODE> property
1159: *
1160: * @return the <CODE>double</CODE> property value for the specified name
1161: *
1162: * @exception JMSException if the JMS provider fails to get the property
1163: * value due to some internal error.
1164: * @exception MessageFormatException if this type conversion is invalid.
1165: */
1166:
1167: double getDoubleProperty(String name) throws JMSException;
1168:
1169: /** Returns the value of the <CODE>String</CODE> property with the specified
1170: * name.
1171: *
1172: * @param name the name of the <CODE>String</CODE> property
1173: *
1174: * @return the <CODE>String</CODE> property value for the specified name;
1175: * if there is no property by this name, a null value is returned
1176: *
1177: * @exception JMSException if the JMS provider fails to get the property
1178: * value due to some internal error.
1179: * @exception MessageFormatException if this type conversion is invalid.
1180: */
1181:
1182: String getStringProperty(String name) throws JMSException;
1183:
1184: /** Returns the value of the Java object property with the specified name.
1185: *
1186: * <P>This method can be used to return, in objectified format,
1187: * an object that has been stored as a property in the message with the
1188: * equivalent <CODE>setObjectProperty</CODE> method call, or its equivalent
1189: * primitive <CODE>set<I>type</I>Property</CODE> method.
1190: *
1191: * @param name the name of the Java object property
1192: *
1193: * @return the Java object property value with the specified name, in
1194: * objectified format (for example, if the property was set as an
1195: * <CODE>int</CODE>, an <CODE>Integer</CODE> is
1196: * returned); if there is no property by this name, a null value
1197: * is returned
1198: *
1199: * @exception JMSException if the JMS provider fails to get the property
1200: * value due to some internal error.
1201: */
1202:
1203: Object getObjectProperty(String name) throws JMSException;
1204:
1205: /** Returns an <CODE>Enumeration</CODE> of all the property names.
1206: *
1207: * <P>Note that JMS standard header fields are not considered
1208: * properties and are not returned in this enumeration.
1209: *
1210: * @return an enumeration of all the names of property values
1211: *
1212: * @exception JMSException if the JMS provider fails to get the property
1213: * names due to some internal error.
1214: */
1215:
1216: Enumeration getPropertyNames() throws JMSException;
1217:
1218: /** Sets a <CODE>boolean</CODE> property value with the specified name into
1219: * the message.
1220: *
1221: * @param name the name of the <CODE>boolean</CODE> property
1222: * @param value the <CODE>boolean</CODE> property value to set
1223: *
1224: * @exception JMSException if the JMS provider fails to set the property
1225: * due to some internal error.
1226: * @exception IllegalArgumentException if the name is null or if the name is
1227: * an empty string.
1228: * @exception MessageNotWriteableException if properties are read-only
1229: */
1230:
1231: void setBooleanProperty(String name, boolean value)
1232: throws JMSException;
1233:
1234: /** Sets a <CODE>byte</CODE> property value with the specified name into
1235: * the message.
1236: *
1237: * @param name the name of the <CODE>byte</CODE> property
1238: * @param value the <CODE>byte</CODE> property value to set
1239: *
1240: * @exception JMSException if the JMS provider fails to set the property
1241: * due to some internal error.
1242: * @exception IllegalArgumentException if the name is null or if the name is
1243: * an empty string.
1244: * @exception MessageNotWriteableException if properties are read-only
1245: */
1246:
1247: void setByteProperty(String name, byte value) throws JMSException;
1248:
1249: /** Sets a <CODE>short</CODE> property value with the specified name into
1250: * the message.
1251: *
1252: * @param name the name of the <CODE>short</CODE> property
1253: * @param value the <CODE>short</CODE> property value to set
1254: *
1255: * @exception JMSException if the JMS provider fails to set the property
1256: * due to some internal error.
1257: * @exception IllegalArgumentException if the name is null or if the name is
1258: * an empty string.
1259: * @exception MessageNotWriteableException if properties are read-only
1260: */
1261:
1262: void setShortProperty(String name, short value) throws JMSException;
1263:
1264: /** Sets an <CODE>int</CODE> property value with the specified name into
1265: * the message.
1266: *
1267: * @param name the name of the <CODE>int</CODE> property
1268: * @param value the <CODE>int</CODE> property value to set
1269: *
1270: * @exception JMSException if the JMS provider fails to set the property
1271: * due to some internal error.
1272: * @exception IllegalArgumentException if the name is null or if the name is
1273: * an empty string.
1274: * @exception MessageNotWriteableException if properties are read-only
1275: */
1276:
1277: void setIntProperty(String name, int value) throws JMSException;
1278:
1279: /** Sets a <CODE>long</CODE> property value with the specified name into
1280: * the message.
1281: *
1282: * @param name the name of the <CODE>long</CODE> property
1283: * @param value the <CODE>long</CODE> property value to set
1284: *
1285: * @exception JMSException if the JMS provider fails to set the property
1286: * due to some internal error.
1287: * @exception IllegalArgumentException if the name is null or if the name is
1288: * an empty string.
1289: * @exception MessageNotWriteableException if properties are read-only
1290: */
1291:
1292: void setLongProperty(String name, long value) throws JMSException;
1293:
1294: /** Sets a <CODE>float</CODE> property value with the specified name into
1295: * the message.
1296: *
1297: * @param name the name of the <CODE>float</CODE> property
1298: * @param value the <CODE>float</CODE> property value to set
1299: *
1300: * @exception JMSException if the JMS provider fails to set the property
1301: * due to some internal error.
1302: * @exception IllegalArgumentException if the name is null or if the name is
1303: * an empty string.
1304: * @exception MessageNotWriteableException if properties are read-only
1305: */
1306:
1307: void setFloatProperty(String name, float value) throws JMSException;
1308:
1309: /** Sets a <CODE>double</CODE> property value with the specified name into
1310: * the message.
1311: *
1312: * @param name the name of the <CODE>double</CODE> property
1313: * @param value the <CODE>double</CODE> property value to set
1314: *
1315: * @exception JMSException if the JMS provider fails to set the property
1316: * due to some internal error.
1317: * @exception IllegalArgumentException if the name is null or if the name is
1318: * an empty string.
1319: * @exception MessageNotWriteableException if properties are read-only
1320: */
1321:
1322: void setDoubleProperty(String name, double value)
1323: throws JMSException;
1324:
1325: /** Sets a <CODE>String</CODE> property value with the specified name into
1326: * the message.
1327: *
1328: * @param name the name of the <CODE>String</CODE> property
1329: * @param value the <CODE>String</CODE> property value to set
1330: *
1331: * @exception JMSException if the JMS provider fails to set the property
1332: * due to some internal error.
1333: * @exception IllegalArgumentException if the name is null or if the name is
1334: * an empty string.
1335: * @exception MessageNotWriteableException if properties are read-only
1336: */
1337:
1338: void setStringProperty(String name, String value)
1339: throws JMSException;
1340:
1341: /** Sets a Java object property value with the specified name into the
1342: * message.
1343: *
1344: * <P>Note that this method works only for the objectified primitive
1345: * object types (<CODE>Integer</CODE>, <CODE>Double</CODE>,
1346: * <CODE>Long</CODE> ...) and <CODE>String</CODE> objects.
1347: *
1348: * @param name the name of the Java object property
1349: * @param value the Java object property value to set
1350: *
1351: * @exception JMSException if the JMS provider fails to set the property
1352: * due to some internal error.
1353: * @exception IllegalArgumentException if the name is null or if the name is
1354: * an empty string.
1355: * @exception MessageFormatException if the object is invalid
1356: * @exception MessageNotWriteableException if properties are read-only
1357: */
1358:
1359: void setObjectProperty(String name, Object value)
1360: throws JMSException;
1361:
1362: /** Acknowledges all consumed messages of the session of this consumed
1363: * message.
1364: *
1365: * <P>All consumed JMS messages support the <CODE>acknowledge</CODE>
1366: * method for use when a client has specified that its JMS session's
1367: * consumed messages are to be explicitly acknowledged. By invoking
1368: * <CODE>acknowledge</CODE> on a consumed message, a client acknowledges
1369: * all messages consumed by the session that the message was delivered to.
1370: *
1371: * <P>Calls to <CODE>acknowledge</CODE> are ignored for both transacted
1372: * sessions and sessions specified to use implicit acknowledgement modes.
1373: *
1374: * <P>A client may individually acknowledge each message as it is consumed,
1375: * or it may choose to acknowledge messages as an application-defined group
1376: * (which is done by calling acknowledge on the last received message of the group,
1377: * thereby acknowledging all messages consumed by the session.)
1378: *
1379: * <P>Messages that have been received but not acknowledged may be
1380: * redelivered.
1381: *
1382: * @exception JMSException if the JMS provider fails to acknowledge the
1383: * messages due to some internal error.
1384: * @exception IllegalStateException if this method is called on a closed
1385: * session.
1386: *
1387: * @see javax.jms.Session#CLIENT_ACKNOWLEDGE
1388: */
1389:
1390: void acknowledge() throws JMSException;
1391:
1392: /** Clears out the message body. Clearing a message's body does not clear
1393: * its header values or property entries.
1394: *
1395: * <P>If this message body was read-only, calling this method leaves
1396: * the message body in the same state as an empty body in a newly
1397: * created message.
1398: *
1399: * @exception JMSException if the JMS provider fails to clear the message
1400: * body due to some internal error.
1401: */
1402:
1403: void clearBody() throws JMSException;
1404: }
|