Scenario Classification #210
Replies: 1 comment
-
Great proposal @francescoloconte On the subject of multiple matching I would propose the following: On the subject of xml based predicates: Agreed, the majority of the rules will be very simple, so it is good to have a simple way to express them |
Beta Was this translation helpful? Give feedback.
-
Deciding the appropriate scenario for a received message is a critical task. We propose defining Scenario Classifiers as predicates that analyze incoming messages to determine if they belong to a specific scenario.
The predicates should support the following tests:
These predicates should be defined as Boolean expressions, supporting compound relational conditions joined by "and," "or," and negation of conditions using the "not" operator.
Orchestra 1.1 RC1 includes the
when
element inmessageType
, which is designed for this task. This element can contain an expression in Score DSL, which can be evaluated using the incoming message as context.Multiple Matching
It is still unclear how the Standard suggests handling cases where multiple scenarios match the incoming message.
One option is to raise an error. The application would then handle it as it does with unrecognized messages. This approach requires careful design of scenario classifiers to ensure there are no ambiguous conditions. It ensures the completeness of Rules of Engagement (RoE) expressed in the Orchestra file.
A more flexible option is to allow multiple scenarios to match a given message and pass all matched messages to the application. The application could then set up a handler to either choose one message from the set or raise an error. This approach adds an extra layer of scenario classification. While it might be less performant and obscure part of the logic from the Orchestra file, it provides better flexibility. Although multiple matching scenarios could be allowed, it can still be avoided by using unambiguous classifiers.
Classification and Validation
Classification is an additional layer of message processing that occurs before validation. To validate a message, it must first be classified to determine which scenario and corresponding validation rules apply. If a message is classified into a scenario but then fails validation, an error must be raised.
Matching Rules
A common scenario arises when there are multiple classification predicates, with one being a specialized version of another (e.g., when one scenario inherits from another). In such cases, it makes sense to perform matching by checking the most specialized predicate first. This can be achieved by introducing a predicate complexity metric.
The complexity can be calculated based on the number of checked entities and the number of checks, with priority given to the variety of checked entities.
Example:
Scenario A applies if the following conditions are met:
The predicate has 2 fields examined with 2 checks.
Scenario B applies if the following conditions are met:
The predicate has 2 fields examined with a total of 3 checks.
When a message matches both scenarios' predicates, Scenario B takes priority.
Optional Matching
In some cases, it is desirable to avoid matching certain message scenarios.
One way to achieve this is by adding a new attribute,
abstract
, to themessageType
. If theabstract
attribute is set totrue
, the message should be skipped from the matching process.<fixr:message name="QuoteRequest" id="26" msgType="R" abstract=”true”>
Another way is to use a special predicate in the
when
element that would never evaluate to true, ensuring the message will not match. Introducing a built-in constant equal tofalse
would facilitate this approach.Predicate Expression Language
The current version of the Orchestra specification proposes using Score DSL to build predicates. This DSL is widely supported in Orchestra for various condition and assignment expressions. Being domain-specific, the language allows expressions to be concise yet readable.
Another option under consideration is to use a simpler syntax built on top of plain XML constructs, with several predefined “check” elements that cover the requirements stated above. This syntax is easy to parse and evaluate. An example is provided below.
The fieldCheck element can support various usage schemas:
<fieldCheck path=”167” value="CDS"/>
<fieldCheck path="448" pattern="[0-9A-Z]{20}"/>
<fieldCheck path=”123” minInclusive="0" maxInclusive=”100”/>
There could be another check types defined, for example to check for element’s existence:
<exists path="447"/>
Beta Was this translation helpful? Give feedback.
All reactions