조건의 자동 예외 처리
규칙 엔진은 Java 예외를 생성하는 규칙 조건을 계속해서 처리합니다.
다음 서브클래스가 규칙 엔진에서 처리됩니다.
- ArithmeticException
- NumberFormatException
- NullPointerException
- IndexOutOfBoundsException
조건의 자동 예외 처리를 통해, 해당 평가 중 예외를 초래한 조건의 표현식은 알 수 없는 값으로 처리되며 규칙 엔진에서 처리됩니다. 규칙 엔진은 다음 세 개의 값이 있는 로직을 사용하여 전체 규칙 조건을 평가합니다.

조건 표현식의 값을 알 수 없어도 규칙 엔진이 규칙 조건을 true 또는 false로 평가하는 경우, 규칙 조치 로직이 적용됩니다. 조건 표현식의 값을 알 수 없어서 규칙 엔진이 규칙 조건을 알 수 없음으로 평가하는 경우 규칙이 실행되지 않습니다.
예를 들어, 다음 규칙에서 고객의 이름 값이 NULL이고 고객의 나이가 20인 경우 첫 번째 조건은 해결되지 않고 두 번째 조건은 충족됩니다.
if the name of the customer is 'Paul'
or the age of the customer is 20
then
reject the loan;
규칙이 논리 or 연산자를 사용하므로 대출 거부 조치가 수행됩니다. 고객의 나이가 20이 아닌 경우 첫 번째 조치는 해결될 수 없고 두 번째 조건은 충족되지 않습니다. 이 경우, 규칙을 실행하지 않으며 대출을 거부하지 않습니다.
지원되는 비즈니스 규칙 언어 표현식
자동 예외 처리는 현재 다음 2개의 비즈니스 규칙 언어 표현식을 지원합니다.
- If there is no ... then ...
- If there is at least one ... then ...
다음 비즈니스 규칙 언어 표현식은 현재 지원되지 않습니다. 그러나, 지원되지 않는 비즈니스 규칙 언어 표현식 중 하나를 사용하도록 결정한 경우 규칙 엔진이 규칙 조건의 평가 중 알 수 없는 값을 현재 무시한다는 것을 이해하십시오.
- If there is no ... then ... else ...
- If there is at least one ... then ... else
- If there are at least <number> ...
- If there are more than <number> ...
- If there are less than <number> ...
- If there are <number> then ... else ...
지원되는 비즈니스 규칙 언어의 표현식을 제외하고, 콜렉션을 사용하는 모든 기타 표현식은 규칙 조건의 평가 중 알 수 없는 값을 무시하는 동일한 로직을 따릅니다.
다음 예제에서, where 절이 2개의 대출자에 대해 참이고 2개의 대출자에 대해 알 수 없음인 경우 규칙 엔진은 규칙 조건이 거짓이라고 간주합니다. else 조치가 수행됩니다.
If there are more than 3 borrowers in the past borrowers of 'the loan' where the name of each borrower is the name of 'the borrower',
then
'대출' 거부;
add “more than 3 similar borrowers found" to the messages of 'the loan' ;
else add “3 or fewer similar borrowers found " to the messages of 'the loan' ;
자동 예외 처리 로그를 사용으로 설정하려면, server.xml에서 로거 이름 com.ibm.rules.engine.aeh를 FINE으로 설정하십시오. Java Logging API에 대한 소개는 Java 로깅 개요를 참조하십시오. java.util.logging Java 로거에 대한 자세한 정보는 Oracle 문서의 java.util.logging을 참조하십시오.
조건의 자동 예외 처리에 대한 예제
- 단순 규칙 조건
다음 예제에서, 대출자의 상태를 알 수 없는 경우 규칙 조치가 실행되지 않습니다.
if the status of 'the borrower' starts with "duplicate" then reject 'the loan' ; add "duplicate detected" to the messages of 'the loan' ; else add "no duplicate found" to the messages of 'the loan' ;- OR 연산자를 사용하는 규칙 조건
다음 예제에서, 대출자의 상태를 알 수 없고 대출의 주석에 duplicate 단어가 포함된 경우, 대출이 거부되고 duplicate detected 메시지가 전송됩니다.
if the status of 'the borrower' starts with "Duplicate" or the comment of 'the loan' contains "duplicate" then reject 'the loan' ; add "duplicate detected" to the messages of 'the loan' ; else add "no duplicate found" to the messages of 'the loan' ;그러나, 대출자의 상태를 알 수 없고 주석을 알 수 없는 경우 규칙 조치가 수행되지 않습니다. 대출이 거부되지 않고 no duplicate found 메시지가 대출에 추가되지 않습니다.
- AND 연산자를 사용하는 규칙 조건
다음 예제에서, 대출자의 상태를 알 수 없고 대출의 주석에 duplicate 단어가 포함된 경우, then 및 else 조치가 둘 다 수행되지 않습니다. 다시 말해서, 대출이 거부되지 않고 no duplicate found 메시지가 대출의 메시지에 추가되지 않습니다.
if the status of 'the borrower' starts with "duplicate" and the comment of 'the loan' contains "duplicate" then reject 'the loan' ; add "duplicate detected" to the messages of 'the loan' ; else add "no duplicate found" to the messages of 'the loan' ;대출이 거부되려면 두 표현식이 모두 참이어야 합니다.
- NOT 연산자를 사용하는 규칙 조건
다음 예제에서, 상태를 알 수 없고 주석에 duplicate가 포함되지 않은 경우, then 조치가 수행되고 no duplicate found입니다.
if it is not true that (the status of 'the borrower' starts with "duplicate" and the comment of 'the loan' contains "duplicate") then add "no duplicate found" to the messages of 'the loan' ; else reject 'the loan' ; add "duplicate detected" to the messages of 'the loan' ;상태를 알 수 없고 주석에 duplicate가 포함된 경우, 규칙 조치가 실행되지 않습니다.
- If there is no ... then ...
과거 대출자의 콜렉션에 where 절이 알 수 없음인 대출자가 포함된 경우 규칙 조치가 수행되지 않습니다.
If there is no borrower in the past borrowers of 'the loan' where the name of this borrower is the name of 'the borrower', then add "no duplicate found" to the message of 'the loan'- If there is at least one ... then ...
과거 대출자의 콜렉션에 where 절이 참인 대출자가 포함된 경우 규칙 조치가 수행됩니다. 과거 대출자의 콜렉션에 where 절이 거짓 또는 알 수 없음인 대출자가 포함된 경우 규칙 조치가 수행되지 않습니다.
If there is at least one borrower in the past borrowers of 'the loan' where the name of this borrower is the name of 'the borrower', then reject 'the loan' ; add "duplicate detected" to the message of 'the loan'- 규칙 변수
규칙 변수 'statusIsNew'가 알 수 없음인 경우, 규칙 엔진이 표현식의 평가를 중지합니다. 조건이 알 수 없음으로 간주되고 규칙 조치가 수행되지 않습니다.
definitions set 'statusIsNew' to the status of 'the borrower' starts with “New"; if it is not true that 'statusIsNew' and the comment of 'the loan' contains "similar" then reject 'the loan' ; add "duplicate detected" to the messages of 'the loan' ; else add "no duplicate found" to the messages of 'the loan' ;- 오브젝트의 콜렉션
콜렉션 오브젝트가 이행해야 하는 테스트에 알 수 없는 값이 있는 경우, 이 오브젝트는 콜렉션에 추가되지 않습니다.
definitions set 'duplicateBorrowers' to all borrowers where the status of each borrower starts with "duplicate" ;- 지원되지 않는 비즈니스 규칙 언어의 표현식
다음 예제에서, where 절이 3개의 대출자에 대해 참이고 하나의 대출자에 대해 알 수 없음인 경우 규칙 엔진은 where 절이 알 수 없음인 대출자가 계산되지 않으므로 조건이 참이라고 간주합니다. then 조치가 수행됩니다.
If there are at most 3 borrowers in the past borrowers of 'the loan' where the name of each borrower is the name of 'the borrower', then add “3 or less similar borrowers found" to the messages of 'the loan' ; else '대출' 거부; add “more than 3 similar borrowers found" to the messages of 'the loan' ;다음 예제에서, where 절이 하나의 대출자에 대해 참이고 2개의 대출자에 대해 알 수 없음인 경우 규칙 엔진은 where 절이 알 수 없음인 2개의 대출자가 계산되지 않으므로 규칙 조건이 거짓이라고 간주합니다. else 조치가 수행됩니다.
if there are at least 3 borrowers in the past borrowers of 'the loan' where the name of each borrower is the name of 'the borrower', then '대출' 거부; add “3 or more similar borrowers found" to the messages of 'the loan' ; else add “less than 3 similar borrowers found" to the messages of 'the loan' ;