Expressions
Expressions are simply literals and identifiers assembled together using the various operators described earlier. A message selector must eventually evaluate to a boolean value, so its combination of expressions must be structured to result in a boolean value. Expressions can be grouped in a message selector using parentheses in order to control the order of evaluation.
Arithmetic expressions are composed of arithmetic operators used with numeric literals and identifier values. Arithmetic expressions can be combined to form compound arithmetic expressions:
(userid + 10000) / (callerid - 10000)
Conditional expressions are made up
of comparison and logical operators used with numeric, string or
boolean literals or identifiers, and evaluate to
true
, false
or
null
(i.e., unknown). Conditional expressions can
also be combined to form compound conditional expressions:
(JMSType like '%Ack') AND ((userid + 10000) / (callerid - 10000) < 1.0)
Notice that, although the last example includes an arithmetic expression fragment:
(userid + 10000) / (callerid - 1000)
it becomes part of a conditional expression when used with a comparison operator with the numeric literal 1.0.
Every complete message selector must be a conditional expression. A
message selector that evaluates to true
matches
the message; one that evaluates to false
or
null
doesn’t match the
message.
Get Java Enterprise in a Nutshell, Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.