1

I'm not sure what is the correct way of handling exceptions in RHS of rules.

I've a statefullSession (drools version 5.5) that keeps firing until halt gets called i.e.

Runnable firingTask = new Runnable() {
public void run() {
    ksession.fireUntilHalt();
};

taskExecutor.execute(firingTask);

The problem is that some parts of my code that gets called as a part of consequence section might throw an exception. If that happens no furher activations happen

My question is: Is there any correct way how application exception should be propagated back to drools? Or is it that any RHS code has to be run inside try/catch block and these exceptions should be propagated as some additional facts into session?

4

1 に答える 1

1

ここでも例外処理の一般的な戦略が適用されますfireUntilHalt

RHS コードのコンテキストで例外を処理する必要がある場合は、try-catch ステートメントを使用する必要があります。それ以外の場合、例外が伝播され、RHS コードの残りの部分は実行されません。(これには、セッションの進行に影響を与える可能性のある変更、挿入、または撤回などの重要なステートメントの省略が含まれる場合があります。)

org.drools.runtime.rule.ConsequenceExceptionの試行で例外をキャッチした場合は、再度fireUntilHalt呼び出すことができますfireUntilHalt。ここでも、前の段落の注意事項が適用されます。

例外をどのようにログに記録するかは完全にあなた次第ですが、例外オブジェクトを事実として挿入する (そしてそれらを推論するためのルールを作成する) ことは、かなり型にはまらないように思えます。

于 2015-12-08T13:29:32.770 に答える