📄 message.html
字号:
<P>JMSX properties defined in the specification as "set by provider on send" are available to both the producer and the consumers of the message. JMSX properties defined in the specification as "set by provider on receive" are available only to the consumers. <P><CODE>JMSXGroupID</CODE> and <CODE>JMSXGroupSeq</CODE> are standard properties that clients should use if they want to group messages. All providers must support them. Unless specifically noted, the values and semantics of the JMSX properties are undefined. <P>The JMS API reserves the <CODE>JMS_<I>vendor_name</I></CODE> property name prefix for provider-specific properties. Each provider defines its own value for <CODE><I>vendor_name</I></CODE>. This is the mechanism a JMS provider uses to make its special per-message services available to a JMS client. <P>The purpose of provider-specific properties is to provide special features needed to integrate JMS clients with provider-native clients in a single JMS application. They should not be used for messaging between JMS clients. <H4>Provider Implementations of JMS Message Interfaces</H4> <P>The JMS API provides a set of message interfaces that define the JMS message model. It does not provide implementations of these interfaces. <P>Each JMS provider supplies a set of message factories with its <CODE>Session</CODE> object for creating instances of messages. This allows a provider to use message implementations tailored to its specific needs. <P>A provider must be prepared to accept message implementations that are not its own. They may not be handled as efficiently as its own implementation; however, they must be handled. <P>Note the following exception case when a provider is handling a foreign message implementation. If the foreign message implementation contains a <CODE>JMSReplyTo</CODE> header field that is set to a foreign destination implementation, the provider is not required to handle or preserve the value of this header field. <H4>Message Selectors</H4> <P>A JMS message selector allows a client to specify, by header field references and property references, the messages it is interested in. Only messages whose header and property values match the selector are delivered. What it means for a message not to be delivered depends on the <CODE>MessageConsumer</CODE> being used (see <A HREF="../../javax/jms/QueueReceiver.html" title="interface in javax.jms"><CODE>QueueReceiver</CODE></A> and <A HREF="../../javax/jms/TopicSubscriber.html" title="interface in javax.jms"><CODE>TopicSubscriber</CODE></A>). <P>Message selectors cannot reference message body values. <P>A message selector matches a message if the selector evaluates to true when the message's header field values and property values are substituted for their corresponding identifiers in the selector. <P>A message selector is a <CODE>String</CODE> whose syntax is based on a subset of the SQL92 conditional expression syntax. If the value of a message selector is an empty string, the value is treated as a null and indicates that there is no message selector for the message consumer. <P>The order of evaluation of a message selector is from left to right within precedence level. Parentheses can be used to change this order. <P>Predefined selector literals and operator names are shown here in uppercase; however, they are case insensitive. <P>A selector can contain: <UL> <LI>Literals: <UL> <LI>A string literal is enclosed in single quotes, with a single quote represented by doubled single quote; for example, <CODE>'literal'</CODE> and <CODE>'literal''s'</CODE>. Like string literals in the Java programming language, these use the Unicode character encoding. <LI>An exact numeric literal is a numeric value without a decimal point, such as <CODE>57</CODE>, <CODE>-957</CODE>, and <CODE>+62</CODE>; numbers in the range of <CODE>long</CODE> are supported. Exact numeric literals use the integer literal syntax of the Java programming language. <LI>An approximate numeric literal is a numeric value in scientific notation, such as <CODE>7E3</CODE> and <CODE>-57.9E2</CODE>, or a numeric value with a decimal, such as <CODE>7.</CODE>, <CODE>-95.7</CODE>, and <CODE>+6.2</CODE>; numbers in the range of <CODE>double</CODE> are supported. Approximate literals use the floating-point literal syntax of the Java programming language. <LI>The boolean literals <CODE>TRUE</CODE> and <CODE>FALSE</CODE>. </UL> <LI>Identifiers: <UL> <LI>An identifier is an unlimited-length sequence of letters and digits, the first of which must be a letter. A letter is any character for which the method <CODE>Character.isJavaLetter</CODE> returns true. This includes <CODE>'_'</CODE> and <CODE>'$'</CODE>. A letter or digit is any character for which the method <CODE>Character.isJavaLetterOrDigit</CODE> returns true. <LI>Identifiers cannot be the names <CODE>NULL</CODE>, <CODE>TRUE</CODE>, and <CODE>FALSE</CODE>. <LI>Identifiers cannot be <CODE>NOT</CODE>, <CODE>AND</CODE>, <CODE>OR</CODE>, <CODE>BETWEEN</CODE>, <CODE>LIKE</CODE>, <CODE>IN</CODE>, <CODE>IS</CODE>, or <CODE>ESCAPE</CODE>. <LI>Identifiers are either header field references or property references. The type of a property value in a message selector corresponds to the type used to set the property. If a property that does not exist in a message is referenced, its value is <CODE>NULL</CODE>. <LI>The conversions that apply to the get methods for properties do not apply when a property is used in a message selector expression. For example, suppose you set a property as a string value, as in the following: <PRE>myMessage.setStringProperty("NumberOfOrders", "2");</PRE> The following expression in a message selector would evaluate to false, because a string cannot be used in an arithmetic expression: <PRE>"NumberOfOrders > 1"</PRE> <LI>Identifiers are case-sensitive. <LI>Message header field references are restricted to <CODE>JMSDeliveryMode</CODE>, <CODE>JMSPriority</CODE>, <CODE>JMSMessageID</CODE>, <CODE>JMSTimestamp</CODE>, <CODE>JMSCorrelationID</CODE>, and <CODE>JMSType</CODE>. <CODE>JMSMessageID</CODE>, <CODE>JMSCorrelationID</CODE>, and <CODE>JMSType</CODE> values may be null and if so are treated as a <CODE>NULL</CODE> value. <LI>Any name beginning with <CODE>'JMSX'</CODE> is a JMS defined property name. <LI>Any name beginning with <CODE>'JMS_'</CODE> is a provider-specific property name. <LI>Any name that does not begin with <CODE>'JMS'</CODE> is an application-specific property name. </UL> <LI>White space is the same as that defined for the Java programming language: space, horizontal tab, form feed, and line terminator. <LI>Expressions: <UL> <LI>A selector is a conditional expression; a selector that evaluates to <CODE>true</CODE> matches; a selector that evaluates to <CODE>false</CODE> or unknown does not match. <LI>Arithmetic expressions are composed of themselves, arithmetic operations, identifiers (whose value is treated as a numeric literal), and numeric literals. <LI>Conditional expressions are composed of themselves, comparison operations, and logical operations. </UL> <LI>Standard bracketing <CODE>()</CODE> for ordering expression evaluation is supported. <LI>Logical operators in precedence order: <CODE>NOT</CODE>, <CODE>AND</CODE>, <CODE>OR</CODE> <LI>Comparison operators: <CODE>=</CODE>, <CODE>></CODE>, <CODE>>=</CODE>, <CODE><</CODE>, <CODE><=</CODE>, <CODE><></CODE> (not equal) <UL> <LI>Only like type values can be compared. One exception is that it is valid to compare exact numeric values and approximate numeric values; the type conversion required is defined by the rules of numeric promotion in the Java programming language. If the comparison of non-like type values is attempted, the value of the operation is false. If either of the type values evaluates to <CODE>NULL</CODE>, the value of the expression is unknown. <LI>String and boolean comparison is restricted to <CODE>=</CODE> and <CODE><></CODE>. Two strings are equal if and only if they contain the same sequence of characters. </UL> <LI>Arithmetic operators in precedence order: <UL> <LI><CODE>+</CODE>, <CODE>-</CODE> (unary) <LI><CODE>*</CODE>, <CODE>/</CODE> (multiplication and division) <LI><CODE>+</CODE>, <CODE>-</CODE> (addition and subtraction) <LI>Arithmetic operations must use numeric promotion in the Java programming language. </UL> <LI><CODE><I>arithmetic-expr1</I> [NOT] BETWEEN <I>arithmetic-expr2</I> AND <I>arithmetic-expr3</I></CODE> (comparison operator) <UL> <LI><CODE>"age BETWEEN 15 AND 19"</CODE> is equivalent to <CODE>"age >= 15 AND age <= 19"</CODE> <LI><CODE>"age NOT BETWEEN 15 AND 19"</CODE> is equivalent to <CODE>"age < 15 OR age > 19"</CODE> </UL> <LI><CODE><I>identifier</I> [NOT] IN (<I>string-literal1</I>, <I>string-literal2</I>,...)</CODE> (comparison operator where <CODE><I>identifier</I></CODE> has a <CODE>String</CODE> or <CODE>NULL</CODE> value) <UL> <LI><CODE>"Country IN (' UK', 'US', 'France')"</CODE> is true for <CODE>'UK'</CODE> and false for <CODE>'Peru'</CODE>; it is equivalent to the expression <CODE>"(Country = ' UK') OR (Country = ' US') OR (Country = ' France')"</CODE> <LI><CODE>"Country NOT IN (' UK', 'US', 'France')"</CODE> is false for <CODE>'UK'</CODE> and true for <CODE>'Peru'</CODE>; it is equivalent to the expression <CODE>"NOT ((Country = ' UK') OR (Country = ' US') OR (Country = ' France'))"</CODE> <LI>If identifier of an <CODE>IN</CODE> or <CODE>NOT IN</CODE> operation is <CODE>NULL</CODE>, the value of the operation is unknown. </UL> <LI><CODE><I>identifier</I> [NOT] LIKE <I>pattern-value</I> [ESCAPE <I>escape-character</I>]</CODE> (comparison operator, where <CODE><I>identifier</I></CODE> has a <CODE>String</CODE> value; <CODE><I>pattern-value</I></CODE> is a string literal where <CODE>'_'</CODE> stands for any single character; <CODE>'%'</CODE> stands for any sequence of characters, including the empty sequence; and all other characters stand for themselves. The optional <CODE><I>escape-character</I></CODE> is a single-character string literal whose character is used to escape the special meaning of the <CODE>'_'</CODE> and <CODE>'%'</CODE> in <CODE><I>pattern-value</I></CODE>.) <UL> <LI><CODE>"phone LIKE '12%3'"</CODE> is true for <CODE>'123'</CODE> or <CODE>'12993'</CODE> and false for <CODE>'1234'</CODE> <LI><CODE>"word LIKE 'l_se'"</CODE> is true for <CODE>'lose'</CODE> and false for <CODE>'loose'</CODE> <LI><CODE>"underscored LIKE '\_%' ESCAPE '\'"</CODE> is true for <CODE>'_foo'</CODE> and false for <CODE>'bar'</CODE> <LI><CODE>"phone NOT LIKE '12%3'"</CODE> is false for <CODE>'123'</CODE> or <CODE>'12993'</CODE> and true for <CODE>'1234'</CODE> <LI>If <CODE><I>identifier</I></CODE> of a <CODE>LIKE</CODE> or <CODE>NOT LIKE</CODE> operation is <CODE>NULL</CODE>, the value of the operation is unknown. </UL> <LI><CODE><I>identifier</I> IS NULL</CODE> (comparison operator that tests for a null header field value or a missing property value) <UL> <LI><CODE>"prop_name IS NULL"</CODE> </UL> <LI><CODE><I>identifier</I> IS NOT NULL</CODE> (comparison operator that tests for the existence of a non-null header field value or a property value) <UL> <LI><CODE>"prop_name IS NOT NULL"</CODE> </UL> <P>JMS providers are required to verify the syntactic correctness of a message selector at the time it is presented. A method that provides a syntactically incorrect selector must result in a <CODE>JMSException</CODE>. JMS providers may also optionally provide some semantic checking at the time the selector is presented. Not all semantic checking can be performed at the time a message selector is presented, because property types are not known. <P>The following message selector selects messages with a message type of car and color of blue and weight greater than 2500 pounds: <PRE>"JMSType = 'car' AND color = 'blue' AND weight > 2500"</PRE> <H4>Null Values</H4> <P>As noted above, property values may be <CODE>NULL</CODE>. The evaluation of selector expressions containing <CODE>NULL</CODE> values is defined by SQL92 <CODE>NULL</CODE> semantics. A brief description of these semantics is provided here. <P>SQL treats a <CODE>NULL</CODE> value as unknown. Comparison or arithmetic with an unknown value always yields an unknown value. <P>The <CODE>IS NULL</CODE> and <CODE>IS NOT NULL</CODE> operators convert an unknown value into the respective <CODE>TRUE</CODE> and <CODE>FALSE</CODE> values. <P>The boolean operators use three-valued logic as defined by the following tables:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -