A message selector is string that lets a client program specify a set of messages, based on the values of message headers and properties. A selector
matches a message if, after substituting header and property values from the message into the selector string, the string evaluates to
true. Consumers can request that the server deliver only those messages that match a selector.
Certain names are exceptions, which cannot be used as identifiers. In particular, NULL,
TRUE,
FALSE,
NOT,
AND,
OR,
BETWEEN,
LIKE,
IN,
IS, and
ESCAPE are defined to have special meaning in message selector syntax.
Identifiers refer either to message header names or property names. The type of an identifier in a message selector corresponds to the type of the header or property value. If an identifier refers to a header or property that does not exist in a message, its value is
NULL.
A string literal is enclosed in single quotes. To represent a single quote within a literal, use two single quotes; for example,
'literal''s'. String literals use the Unicode character encoding. String literals are case sensitive.
An approximate numeric literal is a numeric value with a decimal point (such as 7.,
-95.7, and
+6.2), or a numeric value in scientific notation (such as
7E3 and
-57.9E2); numbers in the range of
double are supported. Approximate literals use the floating-point literal syntax of the Java programming language.
Internal computations of expression values use a 3-value boolean logic similar to SQL. However, the final value of an expression is always either
TRUE or
FALSE—never
UNKNOWN.
Every selector is a conditional expression. A selector that evaluates to true matches the message; a selector that evaluates to
false or unknown does not match.
These operators can compare only values of comparable types. (Exact numeric values and approximate numerical values are comparable types.) Attempting to compare incomparable types yields
false. If either value in a comparison evaluates to
NULL, then the result is unknown (in SQL 3-valued logic).
Comparison of string values is restricted to = and
<>. Two strings are equal if and only if they contain the same sequence of characters. Comparison of boolean values is restricted to
= and
<>.
The BETWEEN comparison operator includes its endpoints. For example:
The identifier must evaluate to either a string or
NULL. If it is
NULL, then the value of this expression is unknown.
The identifier must evaluate to a string.
The pattern-value is a string literal, in which some characters bear special meaning: