1. /*
  2. * Copyright 2002 Sun Microsystems, Inc. All rights reserved.
  3. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  4. */
  5. package javax.jms;
  6. import java.util.Enumeration;
  7. import java.util.Properties;
  8. /** The <CODE>Message</CODE> interface is the root interface of all JMS
  9. * messages. It defines the message header and the <CODE>acknowledge</CODE>
  10. * method used for all messages.
  11. *
  12. * <P>Most message-oriented middleware (MOM) products treat messages as
  13. * lightweight entities that consist
  14. * of a header and a payload. The header contains fields used for message
  15. * routing and identification; the payload contains the application data
  16. * being sent.
  17. *
  18. * <P>Within this general form, the definition of a message varies
  19. * significantly across products. It would be quite difficult for the JMS API
  20. * to support all of these message models.
  21. *
  22. * <P>With this in mind, the JMS message model has the following goals:
  23. * <UL>
  24. * <LI>Provide a single, unified message API
  25. * <LI>Provide an API suitable for creating messages that match the
  26. * format used by provider-native messaging applications
  27. * <LI>Support the development of heterogeneous applications that span
  28. * operating systems, machine architectures, and computer languages
  29. * <LI>Support messages containing objects in the Java programming language
  30. * ("Java objects")
  31. * <LI>Support messages containing Extensible Markup Language (XML) pages
  32. * </UL>
  33. *
  34. * <P>JMS messages are composed of the following parts:
  35. * <UL>
  36. * <LI>Header - All messages support the same set of header fields.
  37. * Header fields contain values used by both clients and providers to
  38. * identify and route messages.
  39. * <LI>Properties - Each message contains a built-in facility for supporting
  40. * application-defined property values. Properties provide an efficient
  41. * mechanism for supporting application-defined message filtering.
  42. * <LI>Body - The JMS API defines several types of message body, which cover
  43. * the majority of messaging styles currently in use.
  44. * </UL>
  45. *
  46. * <H4>Message Bodies</H4>
  47. *
  48. * <P>The JMS API defines five types of message body:
  49. * <UL>
  50. * <LI>Stream - A <CODE>StreamMessage</CODE> object's message body contains
  51. * a stream of primitive values in the Java programming
  52. * language ("Java primitives"). It is filled and read sequentially.
  53. * <LI>Map - A <CODE>MapMessage</CODE> object's message body contains a set
  54. * of name-value pairs, where names are <CODE>String</CODE>
  55. * objects, and values are Java primitives. The entries can be accessed
  56. * sequentially or randomly by name. The order of the entries is
  57. * undefined.
  58. * <LI>Text - A <CODE>TextMessage</CODE> object's message body contains a
  59. * <CODE>java.lang.String</CODE> object. The inclusion
  60. * of this message type is based on our presumption that XML will
  61. * likely become a popular mechanism for representing content of all
  62. * kinds, including the content of JMS messages.
  63. * <LI>Object - An <CODE>ObjectMessage</CODE> object's message body contains
  64. * a <CODE>Serializable</CODE> Java object.
  65. * <LI>Bytes - A <CODE>BytesMessage</CODE> object's message body contains a
  66. * stream of uninterpreted bytes. This message type is for
  67. * literally encoding a body to match an existing message format. In
  68. * many cases, it is possible to use one of the other body types,
  69. * which are easier to use. Although the JMS API allows the use of
  70. * message properties with byte messages, they are typically not used,
  71. * since the inclusion of properties may affect the format.
  72. * </UL>
  73. *
  74. * <H4>Message Headers</H4>
  75. *
  76. * <P>The <CODE>JMSCorrelationID</CODE> header field is used for linking one
  77. * message with
  78. * another. It typically links a reply message with its requesting message.
  79. *
  80. * <P><CODE>JMSCorrelationID</CODE> can hold a provider-specific message ID,
  81. * an application-specific <CODE>String</CODE> object, or a provider-native
  82. * <CODE>byte[]</CODE> value.
  83. *
  84. * <H4>Message Properties</H4>
  85. *
  86. * <P>A <CODE>Message</CODE> object contains a built-in facility for supporting
  87. * application-defined property values. In effect, this provides a mechanism
  88. * for adding application-specific header fields to a message.
  89. *
  90. * <P>Properties allow an application, via message selectors, to have a JMS
  91. * provider select, or filter, messages on its behalf using
  92. * application-specific criteria.
  93. *
  94. * <P>Property names must obey the rules for a message selector identifier.
  95. *
  96. * <P>Property values can be <CODE>boolean</CODE>, <CODE>byte</CODE>,
  97. * <CODE>short</CODE>, <CODE>int</CODE>, <CODE>long</CODE>, <CODE>float</CODE>,
  98. * <CODE>double</CODE>, and <CODE>String</CODE>.
  99. *
  100. * <P>Property values are set prior to sending a message. When a client
  101. * receives a message, its properties are in read-only mode. If a
  102. * client attempts to set properties at this point, a
  103. * <CODE>MessageNotWriteableException</CODE> is thrown. If
  104. * <CODE>clearProperties</CODE> is called, the properties can now be both
  105. * read from and written to. Note that header fields are distinct from
  106. * properties. Header fields are never in read-only mode.
  107. *
  108. * <P>A property value may duplicate a value in a message's body, or it may
  109. * not. Although JMS does not define a policy for what should or should not
  110. * be made a property, application developers should note that JMS providers
  111. * will likely handle data in a message's body more efficiently than data in
  112. * a message's properties. For best performance, applications should use
  113. * message properties only when they need to customize a message's header.
  114. * The primary reason for doing this is to support customized message
  115. * selection.
  116. *
  117. * <P>Message properties support the following conversion table. The marked
  118. * cases must be supported. The unmarked cases must throw a
  119. * <CODE>JMSException</CODE>. The <CODE>String</CODE>-to-primitive conversions
  120. * may throw a runtime exception if the
  121. * primitive's <CODE>valueOf</CODE> method does not accept the
  122. * <CODE>String</CODE> as a valid representation of the primitive.
  123. *
  124. * <P>A value written as the row type can be read as the column type.
  125. *
  126. * <PRE>
  127. * | | boolean byte short int long float double String
  128. * |----------------------------------------------------------
  129. * |boolean | X X
  130. * |byte | X X X X X
  131. * |short | X X X X
  132. * |int | X X X
  133. * |long | X X
  134. * |float | X X X
  135. * |double | X X
  136. * |String | X X X X X X X X
  137. * |----------------------------------------------------------
  138. * </PRE>
  139. *
  140. * <P>In addition to the type-specific set/get methods for properties, JMS
  141. * provides the <CODE>setObjectProperty</CODE> and
  142. * <CODE>getObjectProperty</CODE> methods. These support the same set of
  143. * property types using the objectified primitive values. Their purpose is
  144. * to allow the decision of property type to made at execution time rather
  145. * than at compile time. They support the same property value conversions.
  146. *
  147. * <P>The <CODE>setObjectProperty</CODE> method accepts values of class
  148. * <CODE>Boolean</CODE>, <CODE>Byte</CODE>, <CODE>Short</CODE>,
  149. * <CODE>Integer</CODE>, <CODE>Long</CODE>, <CODE>Float</CODE>,
  150. * <CODE>Double</CODE>, and <CODE>String</CODE>. An attempt
  151. * to use any other class must throw a <CODE>JMSException</CODE>.
  152. *
  153. * <P>The <CODE>getObjectProperty</CODE> method only returns values of class
  154. * <CODE>Boolean</CODE>, <CODE>Byte</CODE>, <CODE>Short</CODE>,
  155. * <CODE>Integer</CODE>, <CODE>Long</CODE>, <CODE>Float</CODE>,
  156. * <CODE>Double</CODE>, and <CODE>String</CODE>.
  157. *
  158. * <P>The order of property values is not defined. To iterate through a
  159. * message's property values, use <CODE>getPropertyNames</CODE> to retrieve
  160. * a property name enumeration and then use the various property get methods
  161. * to retrieve their values.
  162. *
  163. * <P>A message's properties are deleted by the <CODE>clearProperties</CODE>
  164. * method. This leaves the message with an empty set of properties.
  165. *
  166. * <P>Getting a property value for a name which has not been set returns a
  167. * null value. Only the <CODE>getStringProperty</CODE> and
  168. * <CODE>getObjectProperty</CODE> methods can return a null value.
  169. * Attempting to read a null value as a primitive type must be treated as
  170. * calling the primitive's corresponding <CODE>valueOf(String)</CODE>
  171. * conversion method with a null value.
  172. *
  173. * <P>The JMS API reserves the <CODE>JMSX</CODE> property name prefix for JMS
  174. * defined properties.
  175. * The full set of these properties is defined in the Java Message Service
  176. * specification. New JMS defined properties may be added in later versions
  177. * of the JMS API. Support for these properties is optional. The
  178. * <CODE>String[] ConnectionMetaData.getJMSXPropertyNames</CODE> method
  179. * returns the names of the JMSX properties supported by a connection.
  180. *
  181. * <P>JMSX properties may be referenced in message selectors whether or not
  182. * they are supported by a connection. If they are not present in a
  183. * message, they are treated like any other absent property.
  184. *
  185. * <P>JMSX properties defined in the specification as "set by provider on
  186. * send" are available to both the producer and the consumers of the message.
  187. * JMSX properties defined in the specification as "set by provider on
  188. * receive" are available only to the consumers.
  189. *
  190. * <P><CODE>JMSXGroupID</CODE> and <CODE>JMSXGroupSeq</CODE> are standard
  191. * properties that clients
  192. * should use if they want to group messages. All providers must support them.
  193. * Unless specifically noted, the values and semantics of the JMSX properties
  194. * are undefined.
  195. *
  196. * <P>The JMS API reserves the <CODE>JMS_<I>vendor_name</I></CODE> property
  197. * name prefix for provider-specific properties. Each provider defines its own
  198. * value for <CODE><I>vendor_name</I></CODE>. This is the mechanism a JMS
  199. * provider uses to make its special per-message services available to a JMS
  200. * client.
  201. *
  202. * <P>The purpose of provider-specific properties is to provide special
  203. * features needed to integrate JMS clients with provider-native clients in a
  204. * single JMS application. They should not be used for messaging between JMS
  205. * clients.
  206. *
  207. * <H4>Provider Implementations of JMS Message Interfaces</H4>
  208. *
  209. * <P>The JMS API provides a set of message interfaces that define the JMS
  210. * message
  211. * model. It does not provide implementations of these interfaces.
  212. *
  213. * <P>Each JMS provider supplies a set of message factories with its
  214. * <CODE>Session</CODE> object for creating instances of messages. This allows
  215. * a provider to use message implementations tailored to its specific needs.
  216. *
  217. * <P>A provider must be prepared to accept message implementations that are
  218. * not its own. They may not be handled as efficiently as its own
  219. * implementation; however, they must be handled.
  220. *
  221. * <P>Note the following exception case when a provider is handling a foreign
  222. * message implementation. If the foreign message implementation contains a
  223. * <CODE>JMSReplyTo</CODE> header field that is set to a foreign destination
  224. * implementation, the provider is not required to handle or preserve the
  225. * value of this header field.
  226. *
  227. * <H4>Message Selectors</H4>
  228. *
  229. * <P>A JMS message selector allows a client to specify, by
  230. * header field references and property references, the
  231. * messages it is interested in. Only messages whose header
  232. * and property values
  233. * match the
  234. * selector are delivered. What it means for a message not to be delivered
  235. * depends on the <CODE>MessageConsumer</CODE> being used (see
  236. * {@link javax.jms.QueueReceiver QueueReceiver} and
  237. * {@link javax.jms.TopicSubscriber TopicSubscriber}).
  238. *
  239. * <P>Message selectors cannot reference message body values.
  240. *
  241. * <P>A message selector matches a message if the selector evaluates to
  242. * true when the message's header field values and property values are
  243. * substituted for their corresponding identifiers in the selector.
  244. *
  245. * <P>A message selector is a <CODE>String</CODE> whose syntax is based on a
  246. * subset of
  247. * the SQL92 conditional expression syntax. If the value of a message selector
  248. * is an empty string, the value is treated as a null and indicates that there
  249. * is no message selector for the message consumer.
  250. *
  251. * <P>The order of evaluation of a message selector is from left to right
  252. * within precedence level. Parentheses can be used to change this order.
  253. *
  254. * <P>Predefined selector literals and operator names are shown here in
  255. * uppercase; however, they are case insensitive.
  256. *
  257. * <P>A selector can contain:
  258. *
  259. * <UL>
  260. * <LI>Literals:
  261. * <UL>
  262. * <LI>A string literal is enclosed in single quotes, with a single quote
  263. * represented by doubled single quote; for example,
  264. * <CODE>'literal'</CODE> and <CODE>'literal''s'</CODE>. Like
  265. * string literals in the Java programming language, these use the
  266. * Unicode character encoding.
  267. * <LI>An exact numeric literal is a numeric value without a decimal
  268. * point, such as <CODE>57</CODE>, <CODE>-957</CODE>, and
  269. * <CODE>+62</CODE> numbers in the range of <CODE>long</CODE> are
  270. * supported. Exact numeric literals use the integer literal
  271. * syntax of the Java programming language.
  272. * <LI>An approximate numeric literal is a numeric value in scientific
  273. * notation, such as <CODE>7E3</CODE> and <CODE>-57.9E2</CODE>, or a
  274. * numeric value with a decimal, such as <CODE>7.</CODE>,
  275. * <CODE>-95.7</CODE>, and <CODE>+6.2</CODE> numbers in the range of
  276. * <CODE>double</CODE> are supported. Approximate literals use the
  277. * floating-point literal syntax of the Java programming language.
  278. * <LI>The boolean literals <CODE>TRUE</CODE> and <CODE>FALSE</CODE>.
  279. * </UL>
  280. * <LI>Identifiers:
  281. * <UL>
  282. * <LI>An identifier is an unlimited-length sequence of letters
  283. * and digits, the first of which must be a letter. A letter is any
  284. * character for which the method <CODE>Character.isJavaLetter</CODE>
  285. * returns true. This includes <CODE>'_'</CODE> and <CODE>'$'</CODE>.
  286. * A letter or digit is any character for which the method
  287. * <CODE>Character.isJavaLetterOrDigit</CODE> returns true.
  288. * <LI>Identifiers cannot be the names <CODE>NULL</CODE>,
  289. * <CODE>TRUE</CODE>, and <CODE>FALSE</CODE>.
  290. * <LI>Identifiers cannot be <CODE>NOT</CODE>, <CODE>AND</CODE>,
  291. * <CODE>OR</CODE>, <CODE>BETWEEN</CODE>, <CODE>LIKE</CODE>,
  292. * <CODE>IN</CODE>, <CODE>IS</CODE>, or <CODE>ESCAPE</CODE>.
  293. * <LI>Identifiers are either header field references or property
  294. * references. The type of a property value in a message selector
  295. * corresponds to the type used to set the property. If a property
  296. * that does not exist in a message is referenced, its value is
  297. * <CODE>NULL</CODE>.
  298. * <LI>The conversions that apply to the get methods for properties do not
  299. * apply when a property is used in a message selector expression.
  300. * For example, suppose you set a property as a string value, as in the
  301. * following:
  302. * <PRE>myMessage.setStringProperty("NumberOfOrders", "2");</PRE>
  303. * The following expression in a message selector would evaluate to
  304. * false, because a string cannot be used in an arithmetic expression:
  305. * <PRE>"NumberOfOrders > 1"</PRE>
  306. * <LI>Identifiers are case-sensitive.
  307. * <LI>Message header field references are restricted to
  308. * <CODE>JMSDeliveryMode</CODE>, <CODE>JMSPriority</CODE>,
  309. * <CODE>JMSMessageID</CODE>, <CODE>JMSTimestamp</CODE>,
  310. * <CODE>JMSCorrelationID</CODE>, and <CODE>JMSType</CODE>.
  311. * <CODE>JMSMessageID</CODE>, <CODE>JMSCorrelationID</CODE>, and
  312. * <CODE>JMSType</CODE> values may be null and if so are treated as a
  313. * <CODE>NULL</CODE> value.
  314. * <LI>Any name beginning with <CODE>'JMSX'</CODE> is a JMS defined
  315. * property name.
  316. * <LI>Any name beginning with <CODE>'JMS_'</CODE> is a provider-specific
  317. * property name.
  318. * <LI>Any name that does not begin with <CODE>'JMS'</CODE> is an
  319. * application-specific property name.
  320. * </UL>
  321. * <LI>White space is the same as that defined for the Java programming
  322. * language: space, horizontal tab, form feed, and line terminator.
  323. * <LI>Expressions:
  324. * <UL>
  325. * <LI>A selector is a conditional expression; a selector that evaluates
  326. * to <CODE>true</CODE> matches; a selector that evaluates to
  327. * <CODE>false</CODE> or unknown does not match.
  328. * <LI>Arithmetic expressions are composed of themselves, arithmetic
  329. * operations, identifiers (whose value is treated as a numeric
  330. * literal), and numeric literals.
  331. * <LI>Conditional expressions are composed of themselves, comparison
  332. * operations, and logical operations.
  333. * </UL>
  334. * <LI>Standard bracketing <CODE>()</CODE> for ordering expression evaluation
  335. * is supported.
  336. * <LI>Logical operators in precedence order: <CODE>NOT</CODE>,
  337. * <CODE>AND</CODE>, <CODE>OR</CODE>
  338. * <LI>Comparison operators: <CODE>=</CODE>, <CODE>></CODE>, <CODE>>=</CODE>,
  339. * <CODE><</CODE>, <CODE><=</CODE>, <CODE><></CODE> (not equal)
  340. * <UL>
  341. * <LI>Only like type values can be compared. One exception is that it
  342. * is valid to compare exact numeric values and approximate numeric
  343. * values; the type conversion required is defined by the rules of
  344. * numeric promotion in the Java programming language. If the
  345. * comparison of non-like type values is attempted, the value of the
  346. * operation is false. If either of the type values evaluates to
  347. * <CODE>NULL</CODE>, the value of the expression is unknown.
  348. * <LI>String and boolean comparison is restricted to <CODE>=</CODE> and
  349. * <CODE><></CODE>. Two strings are equal
  350. * if and only if they contain the same sequence of characters.
  351. * </UL>
  352. * <LI>Arithmetic operators in precedence order:
  353. * <UL>
  354. * <LI><CODE>+</CODE>, <CODE>-</CODE> (unary)
  355. * <LI><CODE>*</CODE>, <CODE>/</CODE> (multiplication and division)
  356. * <LI><CODE>+</CODE>, <CODE>-</CODE> (addition and subtraction)
  357. * <LI>Arithmetic operations must use numeric promotion in the Java
  358. * programming language.
  359. * </UL>
  360. * <LI><CODE><I>arithmetic-expr1</I> [NOT] BETWEEN <I>arithmetic-expr2</I>
  361. * AND <I>arithmetic-expr3</I></CODE> (comparison operator)
  362. * <UL>
  363. * <LI><CODE>"age BETWEEN 15 AND 19"</CODE> is
  364. * equivalent to
  365. * <CODE>"age >= 15 AND age <= 19"</CODE>
  366. * <LI><CODE>"age NOT BETWEEN 15 AND 19"</CODE>
  367. * is equivalent to
  368. * <CODE>"age < 15 OR age > 19"</CODE>
  369. * </UL>
  370. * <LI><CODE><I>identifier</I> [NOT] IN (<I>string-literal1</I>,
  371. * <I>string-literal2</I>,...)</CODE> (comparison operator where
  372. * <CODE><I>identifier</I></CODE> has a <CODE>String</CODE> or
  373. * <CODE>NULL</CODE> value)
  374. * <UL>
  375. * <LI><CODE>"Country IN (' UK', 'US', 'France')"</CODE>
  376. * is true for
  377. * <CODE>'UK'</CODE> and false for <CODE>'Peru'</CODE> it is
  378. * equivalent to the expression
  379. * <CODE>"(Country = ' UK') OR (Country = ' US') OR (Country = ' France')"</CODE>
  380. * <LI><CODE>"Country NOT IN (' UK', 'US', 'France')"</CODE>
  381. * is false for <CODE>'UK'</CODE> and true for <CODE>'Peru'</CODE> it
  382. * is equivalent to the expression
  383. * <CODE>"NOT ((Country = ' UK') OR (Country = ' US') OR (Country = ' France'))"</CODE>
  384. * <LI>If identifier of an <CODE>IN</CODE> or <CODE>NOT IN</CODE>
  385. * operation is <CODE>NULL</CODE>, the value of the operation is
  386. * unknown.
  387. * </UL>
  388. * <LI><CODE><I>identifier</I> [NOT] LIKE <I>pattern-value</I> [ESCAPE
  389. * <I>escape-character</I>]</CODE> (comparison operator, where
  390. * <CODE><I>identifier</I></CODE> has a <CODE>String</CODE> value;
  391. * <CODE><I>pattern-value</I></CODE> is a string literal where
  392. * <CODE>'_'</CODE> stands for any single character; <CODE>'%'</CODE>
  393. * stands for any sequence of characters, including the empty sequence;
  394. * and all other characters stand for themselves. The optional
  395. * <CODE><I>escape-character</I></CODE> is a single-character string
  396. * literal whose character is used to escape the special meaning of the
  397. * <CODE>'_'</CODE> and <CODE>'%'</CODE> in
  398. * <CODE><I>pattern-value</I></CODE>.)
  399. * <UL>
  400. * <LI><CODE>"phone LIKE '12%3'"</CODE> is true for
  401. * <CODE>'123'</CODE> or <CODE>'12993'</CODE> and false for
  402. * <CODE>'1234'</CODE>
  403. * <LI><CODE>"word LIKE 'l_se'"</CODE> is true for
  404. * <CODE>'lose'</CODE> and false for <CODE>'loose'</CODE>
  405. * <LI><CODE>"underscored LIKE '\_%' ESCAPE '\'"</CODE>
  406. * is true for <CODE>'_foo'</CODE> and false for <CODE>'bar'</CODE>
  407. * <LI><CODE>"phone NOT LIKE '12%3'"</CODE> is false for
  408. * <CODE>'123'</CODE> or <CODE>'12993'</CODE> and true for
  409. * <CODE>'1234'</CODE>
  410. * <LI>If <CODE><I>identifier</I></CODE> of a <CODE>LIKE</CODE> or
  411. * <CODE>NOT LIKE</CODE> operation is <CODE>NULL</CODE>, the value
  412. * of the operation is unknown.
  413. * </UL>
  414. * <LI><CODE><I>identifier</I> IS NULL</CODE> (comparison operator that tests
  415. * for a null header field value or a missing property value)
  416. * <UL>
  417. * <LI><CODE>"prop_name IS NULL"</CODE>
  418. * </UL>
  419. * <LI><CODE><I>identifier</I> IS NOT NULL</CODE> (comparison operator that
  420. * tests for the existence of a non-null header field value or a property
  421. * value)
  422. * <UL>
  423. * <LI><CODE>"prop_name IS NOT NULL"</CODE>
  424. * </UL>
  425. *
  426. * <P>JMS providers are required to verify the syntactic correctness of a
  427. * message selector at the time it is presented. A method that provides a
  428. * syntactically incorrect selector must result in a <CODE>JMSException</CODE>.
  429. *
  430. * <P>The following message selector selects messages with a message type
  431. * of car and color of blue and weight greater than 2500 pounds:
  432. *
  433. * <PRE>"JMSType = 'car' AND color = 'blue' AND weight > 2500"</PRE>
  434. *
  435. * <H4>Null Values</H4>
  436. *
  437. * <P>As noted above, property values may be <CODE>NULL</CODE>. The evaluation
  438. * of selector expressions containing <CODE>NULL</CODE> values is defined by
  439. * SQL92 <CODE>NULL</CODE> semantics. A brief description of these semantics
  440. * is provided here.
  441. *
  442. * <P>SQL treats a <CODE>NULL</CODE> value as unknown. Comparison or arithmetic
  443. * with an unknown value always yields an unknown value.
  444. *
  445. * <P>The <CODE>IS NULL</CODE> and <CODE>IS NOT NULL</CODE> operators convert
  446. * an unknown value into the respective <CODE>TRUE</CODE> and
  447. * <CODE>FALSE</CODE> values.
  448. *
  449. * <P>The boolean operators use three-valued logic as defined by the
  450. * following tables:
  451. *
  452. * <P><B>The definition of the <CODE>AND</CODE> operator</B>
  453. *
  454. * <PRE>
  455. * | AND | T | F | U
  456. * +------+-------+-------+-------
  457. * | T | T | F | U
  458. * | F | F | F | F
  459. * | U | U | F | U
  460. * +------+-------+-------+-------
  461. * </PRE>
  462. *
  463. * <P><B>The definition of the <CODE>OR</CODE> operator</B>
  464. *
  465. * <PRE>
  466. * | OR | T | F | U
  467. * +------+-------+-------+--------
  468. * | T | T | T | T
  469. * | F | T | F | U
  470. * | U | T | U | U
  471. * +------+-------+-------+-------
  472. * </PRE>
  473. *
  474. * <P><B>The definition of the <CODE>NOT</CODE> operator</B>
  475. *
  476. * <PRE>
  477. * | NOT
  478. * +------+------
  479. * | T | F
  480. * | F | T
  481. * | U | U
  482. * +------+-------
  483. * </PRE>
  484. *
  485. * <H4>Special Notes</H4>
  486. *
  487. * <P>When used in a message selector, the <CODE>JMSDeliveryMode</CODE> header
  488. * field is treated as having the values <CODE>'PERSISTENT'</CODE> and
  489. * <CODE>'NON_PERSISTENT'</CODE>.
  490. *
  491. * <P>Date and time values should use the standard <CODE>long</CODE>
  492. * millisecond value. When a date or time literal is included in a message
  493. * selector, it should be an integer literal for a millisecond value. The
  494. * standard way to produce millisecond values is to use
  495. * <CODE>java.util.Calendar</CODE>.
  496. *
  497. * <P>Although SQL supports fixed decimal comparison and arithmetic, JMS
  498. * message selectors do not. This is the reason for restricting exact
  499. * numeric literals to those without a decimal (and the addition of
  500. * numerics with a decimal as an alternate representation for
  501. * approximate numeric values).
  502. *
  503. * <P>SQL comments are not supported.
  504. *
  505. * @version 1.0 - 6 August 1998
  506. * @author Mark Hapner
  507. * @author Rich Burridge
  508. *
  509. * @see javax.jms.MessageConsumer#receive()
  510. * @see javax.jms.MessageConsumer#receive(long)
  511. * @see javax.jms.MessageConsumer#receiveNoWait()
  512. * @see javax.jms.MessageListener#onMessage(Message)
  513. * @see javax.jms.BytesMessage
  514. * @see javax.jms.MapMessage
  515. * @see javax.jms.ObjectMessage
  516. * @see javax.jms.StreamMessage
  517. * @see javax.jms.TextMessage
  518. */
  519. public interface Message {
  520. /** The message producer's default delivery mode is <CODE>PERSISTENT</CODE>.
  521. *
  522. * @see DeliveryMode#PERSISTENT
  523. */
  524. static final int DEFAULT_DELIVERY_MODE = DeliveryMode.PERSISTENT;
  525. /** The message producer's default priority is 4.
  526. */
  527. static final int DEFAULT_PRIORITY = 4;
  528. /** The message producer's default time to live is unlimited; the message
  529. * never expires.
  530. */
  531. static final long DEFAULT_TIME_TO_LIVE = 0;
  532. /** Gets the message ID.
  533. *
  534. * <P>The <CODE>JMSMessageID</CODE> header field contains a value that
  535. * uniquely identifies each message sent by a provider.
  536. *
  537. * <P>When a message is sent, <CODE>JMSMessageID</CODE> can be ignored.
  538. * When the <CODE>send</CODE> or <CODE>publish</CODE> method returns, it
  539. * contains a provider-assigned value.
  540. *
  541. * <P>A <CODE>JMSMessageID</CODE> is a <CODE>String</CODE> value that
  542. * should function as a
  543. * unique key for identifying messages in a historical repository.
  544. * The exact scope of uniqueness is provider-defined. It should at
  545. * least cover all messages for a specific installation of a
  546. * provider, where an installation is some connected set of message
  547. * routers.
  548. *
  549. * <P>All <CODE>JMSMessageID</CODE> values must start with the prefix
  550. * <CODE>'ID:'</CODE>.
  551. * Uniqueness of message ID values across different providers is
  552. * not required.
  553. *
  554. * <P>Since message IDs take some effort to create and increase a
  555. * message's size, some JMS providers may be able to optimize message
  556. * overhead if they are given a hint that the message ID is not used by
  557. * an application. By calling the
  558. * <CODE>MessageProducer.setDisableMessageID</CODE> method, a JMS client
  559. * enables this potential optimization for all messages sent by that
  560. * message producer. If the JMS provider accepts this
  561. * hint, these messages must have the message ID set to null; if the
  562. * provider ignores the hint, the message ID must be set to its normal
  563. * unique value.
  564. *
  565. * @return the message ID
  566. *
  567. * @exception JMSException if the JMS provider fails to get the message ID
  568. * due to some internal error.
  569. * @see javax.jms.Message#setJMSMessageID(String)
  570. * @see javax.jms.MessageProducer#setDisableMessageID(boolean)
  571. */
  572. String
  573. getJMSMessageID() throws JMSException;
  574. /** Sets the message ID.
  575. *
  576. * <P>JMS providers set this field when a message is sent. This method
  577. * can be used to change the value for a message that has been received.
  578. *
  579. * @param id the ID of the message
  580. *
  581. * @exception JMSException if the JMS provider fails to set the message ID
  582. * due to some internal error.
  583. *
  584. * @see javax.jms.Message#getJMSMessageID()
  585. */
  586. void
  587. setJMSMessageID(String id) throws JMSException;
  588. /** Gets the message timestamp.
  589. *
  590. * <P>The <CODE>JMSTimestamp</CODE> header field contains the time a
  591. * message was
  592. * handed off to a provider to be sent. It is not the time the
  593. * message was actually transmitted, because the actual send may occur
  594. * later due to transactions or other client-side queueing of messages.
  595. *
  596. * <P>When a message is sent, <CODE>JMSTimestamp</CODE> is ignored. When
  597. * the <CODE>send</CODE> or <CODE>publish</CODE>
  598. * method returns, it contains a a time value somewhere in the interval
  599. * between the call and the return. The value is in the format of a normal
  600. * millis time value in the Java programming language.
  601. *
  602. * <P>Since timestamps take some effort to create and increase a
  603. * message's size, some JMS providers may be able to optimize message
  604. * overhead if they are given a hint that the timestamp is not used by an
  605. * application. By calling the
  606. * <CODE>MessageProducer.setDisableMessageTimestamp</CODE> method, a JMS
  607. * client enables this potential optimization for all messages sent by
  608. * that message producer. If the JMS provider accepts this
  609. * hint, these messages must have the timestamp set to zero; if the
  610. * provider ignores the hint, the timestamp must be set to its normal
  611. * value.
  612. *
  613. * @return the message timestamp
  614. *
  615. * @exception JMSException if the JMS provider fails to get the timestamp
  616. * due to some internal error.
  617. *
  618. * @see javax.jms.Message#setJMSTimestamp(long)
  619. * @see javax.jms.MessageProducer#setDisableMessageTimestamp(boolean)
  620. */
  621. long
  622. getJMSTimestamp() throws JMSException;
  623. /** Sets the message timestamp.
  624. *
  625. * <P>JMS providers set this field when a message is sent. This method
  626. * can be used to change the value for a message that has been received.
  627. *
  628. * @param timestamp the timestamp for this message
  629. *
  630. * @exception JMSException if the JMS provider fails to set the timestamp
  631. * due to some internal error.
  632. *
  633. * @see javax.jms.Message#getJMSTimestamp()
  634. */
  635. void
  636. setJMSTimestamp(long timestamp) throws JMSException;
  637. /** Gets the correlation ID as an array of bytes for the message.
  638. *
  639. * <P>The use of a <CODE>byte[]</CODE> value for
  640. * <CODE>JMSCorrelationID</CODE> is non-portable.
  641. *
  642. * @return the correlation ID of a message as an array of bytes
  643. *
  644. * @exception JMSException if the JMS provider fails to get the correlation
  645. * ID due to some internal error.
  646. *
  647. * @see javax.jms.Message#setJMSCorrelationID(String)
  648. * @see javax.jms.Message#getJMSCorrelationID()
  649. * @see javax.jms.Message#setJMSCorrelationIDAsBytes(byte[])
  650. */
  651. byte []
  652. getJMSCorrelationIDAsBytes() throws JMSException;
  653. /** Sets the correlation ID as an array of bytes for the message.
  654. *
  655. * <P>The array is copied before the method returns, so
  656. * future modifications to the array will not alter this message header.
  657. *
  658. * <P>If a provider supports the native concept of correlation ID, a
  659. * JMS client may need to assign specific <CODE>JMSCorrelationID</CODE>
  660. * values to match those expected by native messaging clients.
  661. * JMS providers without native correlation ID values are not required to
  662. * support this method and its corresponding get method; their
  663. * implementation may throw a
  664. * <CODE>java.lang.UnsupportedOperationException</CODE>.
  665. *
  666. * <P>The use of a <CODE>byte[]</CODE> value for
  667. * <CODE>JMSCorrelationID</CODE> is non-portable.
  668. *
  669. * @param correlationID the correlation ID value as an array of bytes
  670. *
  671. * @exception JMSException if the JMS provider fails to set the correlation
  672. * ID due to some internal error.
  673. *
  674. * @see javax.jms.Message#setJMSCorrelationID(String)
  675. * @see javax.jms.Message#getJMSCorrelationID()
  676. * @see javax.jms.Message#getJMSCorrelationIDAsBytes()
  677. */
  678. void
  679. setJMSCorrelationIDAsBytes(byte[] correlationID) throws JMSException;
  680. /** Sets the correlation ID for the message.
  681. *
  682. * <P>A client can use the <CODE>JMSCorrelationID</CODE> header field to
  683. * link one message with another. A typical use is to link a response
  684. * message with its request message.
  685. *
  686. * <P><CODE>JMSCorrelationID</CODE> can hold one of the following:
  687. * <UL>
  688. * <LI>A provider-specific message ID
  689. * <LI>An application-specific <CODE>String</CODE>
  690. * <LI>A provider-native <CODE>byte[]</CODE> value
  691. * </UL>
  692. *
  693. * <P>Since each message sent by a JMS provider is assigned a message ID
  694. * value, it is convenient to link messages via message ID. All message ID
  695. * values must start with the <CODE>'ID:'</CODE> prefix.
  696. *
  697. * <P>In some cases, an application (made up of several clients) needs to
  698. * use an application-specific value for linking messages. For instance,
  699. * an application may use <CODE>JMSCorrelationID</CODE> to hold a value
  700. * referencing some external information. Application-specified values
  701. * must not start with the <CODE>'ID:'</CODE> prefix; this is reserved for
  702. * provider-generated message ID values.
  703. *
  704. * <P>If a provider supports the native concept of correlation ID, a JMS
  705. * client may need to assign specific <CODE>JMSCorrelationID</CODE> values
  706. * to match those expected by clients that do not use the JMS API. A
  707. * <CODE>byte[]</CODE> value is used for this
  708. * purpose. JMS providers without native correlation ID values are not
  709. * required to support <CODE>byte[]</CODE> values. The use of a
  710. * <CODE>byte[]</CODE> value for <CODE>JMSCorrelationID</CODE> is
  711. * non-portable.
  712. *
  713. * @param correlationID the message ID of a message being referred to
  714. *
  715. * @exception JMSException if the JMS provider fails to set the correlation
  716. * ID due to some internal error.
  717. *
  718. * @see javax.jms.Message#getJMSCorrelationID()
  719. * @see javax.jms.Message#getJMSCorrelationIDAsBytes()
  720. * @see javax.jms.Message#setJMSCorrelationIDAsBytes(byte[])
  721. */
  722. void
  723. setJMSCorrelationID(String correlationID) throws JMSException;
  724. /** Gets the correlation ID for the message.
  725. *
  726. * <P>This method is used to return correlation ID values that are
  727. * either provider-specific message IDs or application-specific
  728. * <CODE>String</CODE> values.
  729. *
  730. * @return the correlation ID of a message as a <CODE>String</CODE>
  731. *
  732. * @exception JMSException if the JMS provider fails to get the correlation
  733. * ID due to some internal error.
  734. *
  735. * @see javax.jms.Message#setJMSCorrelationID(String)
  736. * @see javax.jms.Message#getJMSCorrelationIDAsBytes()
  737. * @see javax.jms.Message#setJMSCorrelationIDAsBytes(byte[])
  738. */
  739. String
  740. getJMSCorrelationID() throws JMSException;
  741. /** Gets the <CODE>Destination</CODE> object to which a reply to this
  742. * message should be sent.
  743. *
  744. * @return <CODE>Destination</CODE> to which to send a response to this
  745. * message
  746. *
  747. * @exception JMSException if the JMS provider fails to get the
  748. * <CODE>JMSReplyTo</CODE> destination due to some
  749. * internal error.
  750. *
  751. * @see javax.jms.Message#setJMSReplyTo(Destination)
  752. */
  753. Destination
  754. getJMSReplyTo() throws JMSException;
  755. /** Sets the <CODE>Destination</CODE> object to which a reply to this
  756. * message should be sent.
  757. *
  758. * <P>The <CODE>JMSReplyTo</CODE> header field contains the destination
  759. * where a reply
  760. * to the current message should be sent. If it is null, no reply is
  761. * expected. The destination may be either a <CODE>Queue</CODE> object or
  762. * a <CODE>Topic</CODE> object.
  763. *
  764. * <P>Messages sent with a null <CODE>JMSReplyTo</CODE> value may be a
  765. * notification of some event, or they may just be some data the sender
  766. * thinks is of interest.
  767. *
  768. * <P>Messages with a <CODE>JMSReplyTo</CODE> value typically expect a
  769. * response. A response is optional; it is up to the client to decide.
  770. * These messages are called requests. A message sent in response to a
  771. * request is called a reply.
  772. *
  773. * <P>In some cases a client may wish to match a request it sent earlier
  774. * with a reply it has just received. The client can use the
  775. * <CODE>JMSCorrelationID</CODE> header field for this purpose.
  776. *
  777. * @param replyTo <CODE>Destination</CODE> to which to send a response to
  778. * this message
  779. *
  780. * @exception JMSException if the JMS provider fails to set the
  781. * <CODE>JMSReplyTo</CODE> destination due to some
  782. * internal error.
  783. *
  784. * @see javax.jms.Message#getJMSReplyTo()
  785. */
  786. void
  787. setJMSReplyTo(Destination replyTo) throws JMSException;
  788. /** Gets the <CODE>Destination</CODE> object for this message.
  789. *
  790. * <P>The <CODE>JMSDestination</CODE> header field contains the
  791. * destination to which the message is being sent.
  792. *
  793. * <P>When a message is sent, this field is ignored. After completion
  794. * of the <CODE>send</CODE> or <CODE>publish</CODE> method, the field
  795. * holds the destination specified by the method.
  796. *
  797. * <P>When a message is received, its <CODE>JMSDestination</CODE> value
  798. * must be equivalent to the value assigned when it was sent.
  799. *
  800. * @return the destination of this message
  801. *
  802. * @exception JMSException if the JMS provider fails to get the destination
  803. * due to some internal error.
  804. *
  805. * @see javax.jms.Message#setJMSDestination(Destination)
  806. */
  807. Destination
  808. getJMSDestination() throws JMSException;
  809. /** Sets the <CODE>Destination</CODE> object for this message.
  810. *
  811. * <P>JMS providers set this field when a message is sent. This method
  812. * can be used to change the value for a message that has been received.
  813. *
  814. * @param destination the destination for this message
  815. *
  816. * @exception JMSException if the JMS provider fails to set the destination
  817. * due to some internal error.
  818. *
  819. * @see javax.jms.Message#getJMSDestination()
  820. */
  821. void
  822. setJMSDestination(Destination destination) throws JMSException;
  823. /** Gets the <CODE>DeliveryMode</CODE> value specified for this message.
  824. *
  825. * @return the delivery mode for this message
  826. *
  827. * @exception JMSException if the JMS provider fails to get the
  828. * delivery mode due to some internal error.
  829. *
  830. * @see javax.jms.Message#setJMSDeliveryMode(int)
  831. * @see javax.jms.DeliveryMode
  832. */
  833. int
  834. getJMSDeliveryMode() throws JMSException;
  835. /** Sets the <CODE>DeliveryMode</CODE> value for this message.
  836. *
  837. * <P>JMS providers set this field when a message is sent. This method
  838. * can be used to change the value for a message that has been received.
  839. *
  840. * @param deliveryMode the delivery mode for this message
  841. *
  842. * @exception JMSException if the JMS provider fails to set the
  843. * delivery mode due to some internal error.
  844. *
  845. * @see javax.jms.Message#getJMSDeliveryMode()
  846. * @see javax.jms.DeliveryMode
  847. */
  848. void
  849. setJMSDeliveryMode(int deliveryMode) throws JMSException;
  850. /** Gets an indication of whether this message is being redelivered.
  851. *
  852. * <P>If a client receives a message with the <CODE>JMSRedelivered</CODE>
  853. * field set,
  854. * it is likely, but not guaranteed, that this message was delivered
  855. * earlier but that its receipt was not acknowledged
  856. * at that time.
  857. *
  858. * @return true if this message is being redelivered
  859. *
  860. * @exception JMSException if the JMS provider fails to get the redelivered
  861. * state due to some internal error.
  862. *
  863. * @see javax.jms.Message#setJMSRedelivered(boolean)
  864. */
  865. boolean
  866. getJMSRedelivered() throws JMSException;
  867. /** Specifies whether this message is being redelivered.
  868. *
  869. * <P>This field is set at the time the message is delivered. This
  870. * method can be used to change the value for a message that has
  871. * been received.
  872. *
  873. * @param redelivered an indication of whether this message is being
  874. * redelivered
  875. *
  876. * @exception JMSException if the JMS provider fails to set the redelivered
  877. * state due to some internal error.
  878. *
  879. * @see javax.jms.Message#getJMSRedelivered()
  880. */
  881. void
  882. setJMSRedelivered(boolean redelivered) throws JMSException;
  883. /** Gets the message type identifier supplied by the client when the
  884. * message was sent.
  885. *
  886. * @return the message type
  887. *
  888. * @exception JMSException if the JMS provider fails to get the message
  889. * type due to some internal error.
  890. *
  891. * @see javax.jms.Message#setJMSType(String)
  892. */
  893. String
  894. getJMSType() throws JMSException;
  895. /** Sets the message type.
  896. *
  897. * <P>Some JMS providers use a message repository that contains the
  898. * definitions of messages sent by applications. The <CODE>JMSType</CODE>
  899. * header field may reference a message's definition in the provider's
  900. * repository.
  901. *
  902. * <P>The JMS API does not define a standard message definition repository,
  903. * nor does it define a naming policy for the definitions it contains.
  904. *
  905. * <P>Some messaging systems require that a message type definition for
  906. * each application message be created and that each message specify its
  907. * type. In order to work with such JMS providers, JMS clients should
  908. * assign a value to <CODE>JMSType</CODE>, whether the application makes
  909. * use of it or not. This ensures that the field is properly set for those
  910. * providers that require it.
  911. *
  912. * <P>To ensure portability, JMS clients should use symbolic values for
  913. * <CODE>JMSType</CODE> that can be configured at installation time to the
  914. * values defined in the current provider's message repository. If string
  915. * literals are used, they may not be valid type names for some JMS
  916. * providers.
  917. *
  918. * @param type the message type
  919. *
  920. * @exception JMSException if the JMS provider fails to set the message
  921. * type due to some internal error.
  922. *
  923. * @see javax.jms.Message#getJMSType()
  924. */
  925. void
  926. setJMSType(String type) throws JMSException;
  927. /** Gets the message's expiration value.
  928. *
  929. * <P>When a message is sent, the <CODE>JMSExpiration</CODE> header field
  930. * is left unassigned. After completion of the <CODE>send</CODE> or
  931. * <CODE>publish</CODE> method, it holds the expiration time of the
  932. * message. This is the sum of the time-to-live value specified by the
  933. * client and the GMT at the time of the <CODE>send</CODE> or
  934. * <CODE>publish</CODE>.
  935. *
  936. * <P>If the time-to-live is specified as zero, <CODE>JMSExpiration</CODE>
  937. * is set to zero to indicate that the message does not expire.
  938. *
  939. * <P>When a message's expiration time is reached, a provider should
  940. * discard it. The JMS API does not define any form of notification of
  941. * message expiration.
  942. *
  943. * <P>Clients should not receive messages that have expired; however,
  944. * the JMS API does not guarantee that this will not happen.
  945. *
  946. * @return the time the message expires, which is the sum of the
  947. * time-to-live value specified by the client and the GMT at the
  948. * time of the send
  949. *
  950. * @exception JMSException if the JMS provider fails to get the message
  951. * expiration due to some internal error.
  952. *
  953. * @see javax.jms.Message#setJMSExpiration(long)
  954. */
  955. long
  956. getJMSExpiration() throws JMSException;
  957. /** Sets the message's expiration value.
  958. *
  959. * <P>JMS providers set this field when a message is sent. This method
  960. * can be used to change the value for a message that has been received.
  961. *
  962. * @param expiration the message's expiration time
  963. *
  964. * @exception JMSException if the JMS provider fails to set the message
  965. * expiration due to some internal error.
  966. *
  967. * @see javax.jms.Message#getJMSExpiration()
  968. */
  969. void
  970. setJMSExpiration(long expiration) throws JMSException;
  971. /** Gets the message priority level.
  972. *
  973. * <P>The JMS API defines ten levels of priority value, with 0 as the
  974. * lowest
  975. * priority and 9 as the highest. In addition, clients should consider
  976. * priorities 0-4 as gradations of normal priority and priorities 5-9
  977. * as gradations of expedited priority.
  978. *
  979. * <P>The JMS API does not require that a provider strictly implement
  980. * priority
  981. * ordering of messages; however, it should do its best to deliver
  982. * expedited messages ahead of normal messages.
  983. *
  984. * @return the default message priority
  985. *
  986. * @exception JMSException if the JMS provider fails to get the message
  987. * priority due to some internal error.
  988. *
  989. * @see javax.jms.Message#setJMSPriority(int)
  990. */
  991. int
  992. getJMSPriority() throws JMSException;
  993. /** Sets the priority level for this message.
  994. *
  995. * <P>JMS providers set this field when a message is sent. This method
  996. * can be used to change the value for a message that has been received.
  997. *
  998. * @param priority the priority of this message
  999. *
  1000. * @exception JMSException if the JMS provider fails to set the message
  1001. * priority due to some internal error.
  1002. *
  1003. * @see javax.jms.Message#getJMSPriority()
  1004. */
  1005. void
  1006. setJMSPriority(int priority) throws JMSException;
  1007. /** Clears a message's properties.
  1008. *
  1009. * <P>The message's header fields and body are not cleared.
  1010. *
  1011. * @exception JMSException if the JMS provider fails to clear the message
  1012. * properties due to some internal error.
  1013. */
  1014. void
  1015. clearProperties() throws JMSException;
  1016. /** Indicates whether a property value exists.
  1017. *
  1018. * @param name the name of the property to test
  1019. *
  1020. * @return true if the property exists
  1021. *
  1022. * @exception JMSException if the JMS provider fails to determine if the
  1023. * property exists due to some internal error.
  1024. */
  1025. boolean
  1026. propertyExists(String name) throws JMSException;
  1027. /** Returns the value of the <CODE>boolean</CODE> property with the
  1028. * specified name.
  1029. *
  1030. * @param name the name of the <CODE>boolean</CODE> property
  1031. *
  1032. * @return the <CODE>boolean</CODE> property value for the specified name
  1033. *
  1034. * @exception JMSException if the JMS provider fails to get the property
  1035. * value due to some internal error.
  1036. * @exception MessageFormatException if this type conversion is invalid.
  1037. */
  1038. boolean
  1039. getBooleanProperty(String name) throws JMSException;
  1040. /** Returns the value of the <CODE>byte</CODE> property with the specified
  1041. * name.
  1042. *
  1043. * @param name the name of the <CODE>byte</CODE> property
  1044. *
  1045. * @return the <CODE>byte</CODE> property value for the specified name
  1046. *
  1047. * @exception JMSException if the JMS provider fails to get the property
  1048. * value due to some internal error.
  1049. * @exception MessageFormatException if this type conversion is invalid.
  1050. */
  1051. byte
  1052. getByteProperty(String name) throws JMSException;
  1053. /** Returns the value of the <CODE>short</CODE> property with the specified
  1054. * name.
  1055. *
  1056. * @param name the name of the <CODE>short</CODE> property
  1057. *
  1058. * @return the <CODE>short</CODE> property value for the specified name
  1059. *
  1060. * @exception JMSException if the JMS provider fails to get the property
  1061. * value due to some internal error.
  1062. * @exception MessageFormatException if this type conversion is invalid.
  1063. */
  1064. short
  1065. getShortProperty(String name) throws JMSException;
  1066. /** Returns the value of the <CODE>int</CODE> property with the specified
  1067. * name.
  1068. *
  1069. * @param name the name of the <CODE>int</CODE> property
  1070. *
  1071. * @return the <CODE>int</CODE> property value for the specified name
  1072. *
  1073. * @exception JMSException if the JMS provider fails to get the property
  1074. * value due to some internal error.
  1075. * @exception MessageFormatException if this type conversion is invalid.
  1076. */
  1077. int
  1078. getIntProperty(String name) throws JMSException;
  1079. /** Returns the value of the <CODE>long</CODE> property with the specified
  1080. * name.
  1081. *
  1082. * @param name the name of the <CODE>long</CODE> property
  1083. *
  1084. * @return the <CODE>long</CODE> property value for the specified name
  1085. *
  1086. * @exception JMSException if the JMS provider fails to get the property
  1087. * value due to some internal error.
  1088. * @exception MessageFormatException if this type conversion is invalid.
  1089. */
  1090. long
  1091. getLongProperty(String name) throws JMSException;
  1092. /** Returns the value of the <CODE>float</CODE> property with the specified
  1093. * name.
  1094. *
  1095. * @param name the name of the <CODE>float</CODE> property
  1096. *
  1097. * @return the <CODE>float</CODE> property value for the specified name
  1098. *
  1099. * @exception JMSException if the JMS provider fails to get the property
  1100. * value due to some internal error.
  1101. * @exception MessageFormatException if this type conversion is invalid.
  1102. */
  1103. float
  1104. getFloatProperty(String name) throws JMSException;
  1105. /** Returns the value of the <CODE>double</CODE> property with the specified
  1106. * name.
  1107. *
  1108. * @param name the name of the <CODE>double</CODE> property
  1109. *
  1110. * @return the <CODE>double</CODE> property value for the specified name
  1111. *
  1112. * @exception JMSException if the JMS provider fails to get the property
  1113. * value due to some internal error.
  1114. * @exception MessageFormatException if this type conversion is invalid.
  1115. */
  1116. double
  1117. getDoubleProperty(String name) throws JMSException;
  1118. /** Returns the value of the <CODE>String</CODE> property with the specified
  1119. * name.
  1120. *
  1121. * @param name the name of the <CODE>String</CODE> property
  1122. *
  1123. * @return the <CODE>String</CODE> property value for the specified name;
  1124. * if there is no property by this name, a null value is returned
  1125. *
  1126. * @exception JMSException if the JMS provider fails to get the property
  1127. * value due to some internal error.
  1128. * @exception MessageFormatException if this type conversion is invalid.
  1129. */
  1130. String
  1131. getStringProperty(String name) throws JMSException;
  1132. /** Returns the value of the Java object property with the specified name.
  1133. *
  1134. * <P>This method can be used to return, in objectified format,
  1135. * an object that has been stored as a property in the message with the
  1136. * equivalent <CODE>setObjectProperty</CODE> method call, or its equivalent
  1137. * primitive <CODE>set<I>type</I>Property</CODE> method.
  1138. *
  1139. * @param name the name of the Java object property
  1140. *
  1141. * @return the Java object property value with the specified name, in
  1142. * objectified format (for example, if the property was set as an
  1143. * <CODE>int</CODE>, an <CODE>Integer</CODE> is
  1144. * returned); if there is no property by this name, a null value
  1145. * is returned
  1146. *
  1147. * @exception JMSException if the JMS provider fails to get the property
  1148. * value due to some internal error.
  1149. */
  1150. Object
  1151. getObjectProperty(String name) throws JMSException;
  1152. /** Returns an <CODE>Enumeration</CODE> of all the property names.
  1153. *
  1154. * <P>Note that JMS standard header fields are not considered
  1155. * properties and are not returned in this enumeration.
  1156. *
  1157. * @return an enumeration of all the names of property values
  1158. *
  1159. * @exception JMSException if the JMS provider fails to get the property
  1160. * names due to some internal error.
  1161. */
  1162. Enumeration
  1163. getPropertyNames() throws JMSException;
  1164. /** Sets a <CODE>boolean</CODE> property value with the specified name into
  1165. * the message.
  1166. *
  1167. * @param name the name of the <CODE>boolean</CODE> property
  1168. * @param value the <CODE>boolean</CODE> property value to set
  1169. *
  1170. * @exception JMSException if the JMS provider fails to set the property
  1171. * due to some internal error.
  1172. * @exception MessageNotWriteableException if properties are read-only
  1173. */
  1174. void
  1175. setBooleanProperty(String name, boolean value)
  1176. throws JMSException;
  1177. /** Sets a <CODE>byte</CODE> property value with the specified name into
  1178. * the message.
  1179. *
  1180. * @param name the name of the <CODE>byte</CODE> property
  1181. * @param value the <CODE>byte</CODE> property value to set
  1182. *
  1183. * @exception JMSException if the JMS provider fails to set the property
  1184. * due to some internal error.
  1185. * @exception MessageNotWriteableException if properties are read-only
  1186. */
  1187. void
  1188. setByteProperty(String name, byte value)
  1189. throws JMSException;
  1190. /** Sets a <CODE>short</CODE> property value with the specified name into
  1191. * the message.
  1192. *
  1193. * @param name the name of the <CODE>short</CODE> property
  1194. * @param value the <CODE>short</CODE> property value to set
  1195. *
  1196. * @exception JMSException if the JMS provider fails to set the property
  1197. * due to some internal error.
  1198. * @exception MessageNotWriteableException if properties are read-only
  1199. */
  1200. void
  1201. setShortProperty(String name, short value)
  1202. throws JMSException;
  1203. /** Sets an <CODE>int</CODE> property value with the specified name into
  1204. * the message.
  1205. *
  1206. * @param name the name of the <CODE>int</CODE> property
  1207. * @param value the <CODE>int</CODE> property value to set
  1208. *
  1209. * @exception JMSException if the JMS provider fails to set the property
  1210. * due to some internal error.
  1211. * @exception MessageNotWriteableException if properties are read-only
  1212. */
  1213. void
  1214. setIntProperty(String name, int value)
  1215. throws JMSException;
  1216. /** Sets a <CODE>long</CODE> property value with the specified name into
  1217. * the message.
  1218. *
  1219. * @param name the name of the <CODE>long</CODE> property
  1220. * @param value the <CODE>long</CODE> property value to set
  1221. *
  1222. * @exception JMSException if the JMS provider fails to set the property
  1223. * due to some internal error.
  1224. * @exception MessageNotWriteableException if properties are read-only
  1225. */
  1226. void
  1227. setLongProperty(String name, long value)
  1228. throws JMSException;
  1229. /** Sets a <CODE>float</CODE> property value with the specified name into
  1230. * the message.
  1231. *
  1232. * @param name the name of the <CODE>float</CODE> property
  1233. * @param value the <CODE>float</CODE> property value to set
  1234. *
  1235. * @exception JMSException if the JMS provider fails to set the property
  1236. * due to some internal error.
  1237. * @exception MessageNotWriteableException if properties are read-only
  1238. */
  1239. void
  1240. setFloatProperty(String name, float value)
  1241. throws JMSException;
  1242. /** Sets a <CODE>double</CODE> property value with the specified name into
  1243. * the message.
  1244. *
  1245. * @param name the name of the <CODE>double</CODE> property
  1246. * @param value the <CODE>double</CODE> property value to set
  1247. *
  1248. * @exception JMSException if the JMS provider fails to set the property
  1249. * due to some internal error.
  1250. * @exception MessageNotWriteableException if properties are read-only
  1251. */
  1252. void
  1253. setDoubleProperty(String name, double value)
  1254. throws JMSException;
  1255. /** Sets a <CODE>String</CODE> property value with the specified name into
  1256. * the message.
  1257. *
  1258. * @param name the name of the <CODE>String</CODE> property
  1259. * @param value the <CODE>String</CODE> property value to set
  1260. *
  1261. * @exception JMSException if the JMS provider fails to set the property
  1262. * due to some internal error.
  1263. * @exception MessageNotWriteableException if properties are read-only
  1264. */
  1265. void
  1266. setStringProperty(String name, String value)
  1267. throws JMSException;
  1268. /** Sets a Java object property value with the specified name into the
  1269. * message.
  1270. *
  1271. * <P>Note that this method works only for the objectified primitive
  1272. * object types (<CODE>Integer</CODE>, <CODE>Double</CODE>,
  1273. * <CODE>Long</CODE> ...) and <CODE>String</CODE> objects.
  1274. *
  1275. * @param name the name of the Java object property
  1276. * @param value the Java object property value to set
  1277. *
  1278. * @exception JMSException if the JMS provider fails to set the property
  1279. * due to some internal error.
  1280. * @exception MessageFormatException if the object is invalid
  1281. * @exception MessageNotWriteableException if properties are read-only
  1282. */
  1283. void
  1284. setObjectProperty(String name, Object value)
  1285. throws JMSException;
  1286. /** Acknowledges all consumed messages of the session of this consumed
  1287. * message.
  1288. *
  1289. * <P>All consumed JMS messages support the <CODE>acknowledge</CODE>
  1290. * method for use when a client has specified that its JMS session's
  1291. * consumed messages are to be explicitly acknowledged. By invoking
  1292. * <CODE>acknowledge</CODE> on a consumed message, a client acknowledges
  1293. * all messages consumed by the session that the message was delivered to.
  1294. *
  1295. * <P>Calls to <CODE>acknowledge</CODE> are ignored for both transacted
  1296. * sessions and sessions specified to use implicit acknowledgement modes.
  1297. *
  1298. * <P>A client may individually acknowledge each message as it is consumed,
  1299. * or it may choose to acknowledge messages as an application-defined group
  1300. * (which is done by calling acknowledge on the last received message of the group,
  1301. * thereby acknowledging all messages consumed by the session.)
  1302. *
  1303. * <P>Messages that have been received but not acknowledged may be
  1304. * redelivered.
  1305. *
  1306. * @exception JMSException if the JMS provider fails to acknowledge the
  1307. * messages due to some internal error.
  1308. * @exception IllegalStateException if this method is called on a closed
  1309. * session.
  1310. *
  1311. * @see javax.jms.Session#CLIENT_ACKNOWLEDGE
  1312. */
  1313. void
  1314. acknowledge() throws JMSException;
  1315. /** Clears out the message body. Clearing a message's body does not clear
  1316. * its header values or property entries.
  1317. *
  1318. * <P>If this message body was read-only, calling this method leaves
  1319. * the message body in the same state as an empty body in a newly
  1320. * created message.
  1321. *
  1322. * @exception JMSException if the JMS provider fails to clear the message
  1323. * body due to some internal error.
  1324. */
  1325. void
  1326. clearBody() throws JMSException;
  1327. }