조건의 자동 예외 처리
의사결정 서비스 프로젝트 레벨에서 예외 처리를 자동화하여, 규칙 엔진에서 Java 예외를 생성하는 규칙 조건을 계속해서 처리하도록 할 수 있습니다. 조건의 자동 예외 처리를 활성화하는 경우 엔진에서 기본적으로 4개의 Java 예외 유형을 처리하지만 규칙 엔진이 처리하는 Java 예외 유형의 목록을 사용자가 사용자 정의할 수 있습니다.
Rule Designer에서, 규칙 프로젝트 특성 창의 규칙 엔진 패널에서 자동 예외 처리를 사용 또는 사용 안함으로 설정할 수 있습니다. 자동 예외 처리는 기본적으로 사용 안함으로 설정됩니다.
자동 예외 처리가 사용으로 설정된 경우 규칙 엔진에서 다음 서브클래스가 처리됩니다.
- ArithmeticException
- NumberFormatException
- NullPointerException
- IndexOutOfBoundsException
조건의 자동 예외 처리가 사용으로 설정되면, 평가 중 예외를 초래하는 조건의 표현식이 알려지지 않은 값으로 처리되고 규칙 엔진에서 처리됩니다. 규칙 엔진은 다음 세 개의 값이 있는 로직을 사용하여 전체 규칙 조건을 평가합니다.

규칙 엔진이 규칙 조건을 true 또는 false로 평가하는 경우, 조건 표현식의 값을 알 수 없어도 규칙 조치 로직이 적용됩니다. 규칙 엔진이 규칙 조건을 알 수 없음으로 평가하는 경우 조건 표현식의 값을 알 수 없으므로 규칙이 실행되지 않습니다.
예를 들어 다음 규칙에서 고객 이름 값이 널이고 고객 연령이 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' ;
추가 예제는 지원되지 않는 비즈니스 언어의 표현식의 내용을 참조하십시오.
예외 유형 추가
해당하는 클래스로 BOM을 작성하고 특정 특성을 추가하여 특정 특성 de.autoCatchExceptionInConditions 및 de.doNotAutoCatchExceptionInConditions를 적절히 각 클래스에 추가하여 자동으로 처리된 예외 유형의 목록을 사용자 정의할 수 있습니다. 자동 예외 처리가 Rule Designer에서 사용으로 설정되면, 다음 서브클래스에 속한 예외에 대해 규칙의 조건 파트에서 발생하는 예외를 자동으로 처리하도록 작동합니다.
- ArithmeticException
- NumberFormatException
- NullPointerException
- IndexOutOfBoundsException
BOM 편집기를 통해 해당하는 클래스에 de.autoCatchExceptionInConditions 특성을 설정하여 자동으로 처리될 예외 유형을 추가하도록 기본 동작을 사용자 정의할 수 있습니다.
package java.lang;
public class ClassCastException
extends java.lang.RuntimeException
property "de.autoCatchExceptionInConditions" "true"
{
public ClassCastException();
public ClassCastException(string arg);
}
예외 유형 제외
de.autoCatchExceptionInConditions 특성으로 BOM의 클래스 정의를 오버라이드하여 처리된 클래스 중 하나의 자동 예외 처리에서 예외 유형을 제외할 수 있습니다. 예를 들어, ArithmeticException 클래스에서 de.autoCatchExceptionInConditions 특성(굵은체)을 설정하여 자동 예외 처리에서 산술 예외를 제거할 수 있습니다.
public class ArithmeticException
extends java.lang.RuntimeException
property "de.autoCatchExceptionInConditions" "true"
{
public ArithmeticException();
public ArithmeticException(string arg);
}
de.doNotAutoCatchExceptionInConditions(굵은체) 특성을 설정하여 자동 예외 처리에서 4개의 기본 클래스 중 서브클래스를 제외할 수 있습니다.
public class StringIndexOutOfBoundsException
extends java.lang.IndexOutOfBoundsException
property "de.doNotAutoCatchExceptionInConditions" "true"
{
public StringIndexOutOfBoundsException();
public StringIndexOutOfBoundsException(string arg);
public StringIndexOutOfBoundsException(int arg);
}
로깅
자동 예외 처리는 표준 Java™ 로거 로깅 서비스를 사용하여, 사용자가 메시지 유형 및 레벨에 기반하여 메시지를 로그하고 이러한 메시지가 런타임 시 형식화되고 저장되는 방식을 제어할 수 있도록 합니다.
Rule Designer에서, 자동 예외 처리에 발생하는 활동 추적을 캡처하려면 logging.properties 파일을 먼저 정의하고 규칙 실행 또는 디버그 구성에 사용되는 JVM에 사용 가능하도록 해야 합니다. 그런 다음, Run Configurations 창에서 의사결정 오퍼레이션의 매개변수 & 인수 탭 아래에 다음 VM 인수를 입력하십시오. -Djava.util.logging.config.file=file_path/logging.properties
handlers = java.util.logging.ConsoleHandler
# Set the default logging level for the root logger
.level = ALL
############################################################
# Handler specific properties.
# Describes specific configuration info for Handlers.
############################################################
# Limit the messages that are printed on the console to INFO and above.
java.util.logging.ConsoleHandler.level = FINE
java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
com.ibm.rules.engine.aeh = FINE
서버 환경에서 자동 예외 처리 로그를 사용으로 설정하려면, logging.properties 파일을 정의하고 애플리케이션 서버 구성을 통해 JVM에 사용 가능하도록 하십시오. com.ibm.rules.engine.aeh 로거의 로그 레벨이 FINE으로 설정되어야 합니다.
Java Logging API에 대한 소개는 Java 로깅 개요를 참조하십시오. java.util.logging Java 로거에 대한 자세한 정보는 Oracle 문서의 java.util.logging을 참조하십시오.