Show TOC Start of Content Area

Background documentation Message Selector Syntax  Locate the document in its SAP Library structure

The message selector is a string 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 current message consumer. The order of evaluation of a message selector is from left to right within the precedence level. Parentheses can be used to change this order. Predefined selector literals and operator names that are written here in upper case are case insensitive.

A selector can contain:

      Literals

       A string literal is enclosed in single quotes, with an included single quote represented by doubled single quote; for example, ‘literal’ and ‘literal’s’. These use the Unicode character encoding.

¡        An exact numeric literal is a numeric value without a decimal point, such as 57, -957, +62. These numeric use the Java integer literal syntax.

¡        An approximate numeric literal is a numeric value in scientific notation, such as 7E3 and -57.9E2, or a numeric value with a decimal, such as 7., 95.7, and +6.2; numbers in the range of Java double are supported.

¡        Approximate literals use the Java floating-point literal syntax. The Boolean literals TRUE and FALSE.

·        Identifiers:

       An identifier is an unlimited-length character sequence that must begin with a Java identifier start character. All following characters must be Java identifier part characters. An identifier start character is any character for which the method Character.isJavaIdentifierStart() returns true. This includes ‘_’ and ‘$’. An identifier part character is any character for which the method Character.isJavaIdentifierPart() returns true.

¡        Identifiers cannot be the names NULL, TRUE, or FALSE.

¡        Identifiers cannot be NOT, AND, OR, BETWEEN, LIKE, IN, IS, or ESCAPE.

¡        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 NULL.

¡        The conversions that apply to the get() methods for properties do not apply when a property is used in a message selector expression.

 Note

You set a property as a string value:

myMessage.setStringProperty("NumberOfOrders", "2");

The following expression in a message selector would evaluate to false, because a string cannot be used in an arithmetic expression: "NumberOfOrders > 1"

¡        Identifiers are case sensitive.

¡        Message header field references are restricted to JMSDeliveryMode, JMSPriority, JMSMessageID, JMSTimestamp, JMSCorrelationID, and JMSType. JMSMessageID, JMSCorrelationID, and JMSType values may be null and if so are treated as a NULL value. For more information about the headers, see JMS Messages.

       Any name beginning with ‘JMSX’ is a JMS defined property name.

       Any name beginning with ‘JMS_’ is a provider-specific property name.

       Any name that does not begin with ‘JMS’ is an application-specific property name. Whitespace is the same as that defined for Java: space, horizontal tab, form feed and line terminator.

      Expressions:

       A selector is a conditional expression: a selector that evaluates to true matches; a selector that evaluates to false or unknown does not match.

       Arithmetic expressions are composed of themselves, arithmetic operations, identifiers with numeric values, and numeric literals.

       Conditional expressions are composed of themselves, comparison operations, logical operations, identifiers with Boolean values, and Boolean literals.

      Standard bracketing () for ordering expression evaluation is supported.

      Logical operators in precedence order: NOT, AND, OR

      Comparison operators: =, >, >=, <, <=, <> (not equal)

       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 Java numeric promotion). 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 NULL, the value of the expression is unknown.

       String and Boolean comparison is restricted to = and <>. Two strings are equal if and only if they contain the same sequence of characters.

      Arithmetic operators in precedence order:

       +, - (unary)

       *, / (multiplication and division)

       +, - (addition and subtraction)

       Arithmetic operations must use Java numeric promotion.

      arithmetic-expr1 [NOT] BETWEEN arithmetic-expr2 and arithmetic-expr3 (comparison operator)

       “salary BETWEEN 2300 AND 2600” is equivalent to “salary >= 2300 AND age <= 2600”

       “salary NOT BETWEEN 2300 AND 2600” is equivalent to “salary < 2300 OR salary > 2600”

      identifier [NOT] IN(string-literal1, string-literal2,...) (comparison operator where the identifier has a string or NULL value)

       “Department IN (’Management’, ’Marketing’, ’Research’)” is true for “Management’” and false for “Development’’; it is equivalent to the expression ”( Department = ’Management’) OR (Department = ’Marketing’) OR (Department = ’Research’)”

       “Department NOT IN (’Management’, ’Marketing’, ‘Research’)” is false for ‘’Management”  and true for “Development’’; it is equivalent to the expression “NOT ((Department = ’Management’) OR (Department = ’Marketing’) OR (Department = ’Research’))”

       If the identifier of an IN or NOT IN operation is NULL, the value of the operation is unknown.

      identifier [NOT] LIKE pattern-value [ESCAPE escape-character] (comparison operator, where the identifier has a string value; pattern-value is a string literal where ‘_’ stands for any single character; ‘%’ stands for any sequence of characters, including the empty sequence, and all other characters stand for themselves. The optional escape-character is a single-character string literal whose character is used to escape the special meaning of the ‘_’ and ‘%’ in pattern-value.)

       “phone LIKE ‘ab%c’” is true for ‘abc’ or ‘abxyc’ and false for ‘abcd’.

       “word LIKE ‘chose_’” is true for ‘chose’ and false for ‘chosen’.

       “underscored LIKE ‘\_%’ ESCAPE ‘\’” is true for ‘_under’ and false for ‘over’.

       “phone NOT LIKE ‘ab%c’” is false for ‘abc’ and ‘abxyc’ and true for ‘abcd’.

       If the identifier of a LIKE or NOT LIKE operation is NULL, the value of the operation is unknown.

      identifier IS NULL (comparison operator that tests for a null header field value or a missing property value)

       “prop_name IS NULL”

      identifier IS NOT NULL(comparison operator that tests for the existence of a non-null header field value or property value)

       “prop_name IS NOT NULL”

The JMS provider verifies the syntactic correctness of a message selector at the time it is presented. A method providing a syntactically incorrect selector results in InvalidSelectorException.

 

End of Content Area