Я пытаюсь вставить в журналы, сгенерированные функцией KieRunTimeLogger, с периодическими интервалами, потому что мой «идентификатор заявки» (переменная, которую я беру из getter), изменяется, поскольку он перебирает объект, и только последнее значение вставляется послеВызывается «Ksession.execute».
Я использовал глобальную строку с именем «globalStringK» (в журнале ниже), чтобы добавить все «идентификатор заявки», которые были проанализированы.Но посмотрите на «идентификатор заявки» в журнале, выполняется только последнее «число».
В журнале показаны все правила, которые были применены в файле .drl, но мне нужен «идентификатор заявки»быть вставленным своевременно, чтобы сказать, какое правило попадало в какой объект, а не перезаписываться.
Я ссылался на эти https://access.redhat.com/documentation/en-us/red_hat_jboss_bpm_suite/6.1/html/development_guide/sect-kie_sessions и пытался использовать следующую ссылку и пытался добавить это.Правильный ли это подход.
Например,
StatelessKieSession kSession = kContainer.newStatelessKieSession();
Applicant applicant = new Applicant( "Mr John Smith", 16 );
assertTrue( applicant.isValid() );
ksession.execute( applicant );
assertFalse( applicant.isValid() );
Это мой сгенерированный журнал сгенерированного потока объектов для приложения.
<object-stream>
<org.drools.core.audit.WorkingMemoryLog>
<version>6.1</version>
<events>
<org.drools.core.audit.event.ObjectLogEvent>
<type>1</type>
<factId>1</factId>
<objectToString>globalStringK = EK0970218 XB9772517 DQ6175084 EK0970518</objectToString>
</org.drools.core.audit.event.ObjectLogEvent>
<org.drools.core.audit.event.ObjectLogEvent>
<type>1</type>
<factId>1</factId>
<objectToString>claim ID = EK0970518</objectToString>
</org.drools.core.audit.event.ObjectLogEvent>
<org.drools.core.audit.event.ObjectLogEvent>
<type>1</type>
<factId>1</factId>
<objectToString>com.rsrit.cob.Variables.ClaimInfo@5774994a</objectToString>
</org.drools.core.audit.event.ObjectLogEvent>
<org.drools.core.audit.event.ActivationLogEvent>
<type>4</type>
<activationId>recovery default [1]</activationId>
<rule>recovery default</rule>
<declarations>$a1=com.rsrit.cob.Variables.ClaimInfo@5774994a</declarations>
<factHandleIds>1</factHandleIds>
</org.drools.core.audit.event.ActivationLogEvent>
<org.drools.core.audit.event.ActivationLogEvent>
<type>6</type>
<activationId>recovery default [1]</activationId>
<rule>recovery default</rule>
<declarations>$a1=com.rsrit.cob.Variables.ClaimInfo@5774994a</declarations>
<factHandleIds>1</factHandleIds>
</org.drools.core.audit.event.ActivationLogEvent>
<org.drools.core.audit.event.ActivationLogEvent>
<type>7</type>
<activationId>recovery default [1]</activationId>
<rule>recovery default</rule>
<declarations>$a1=com.rsrit.cob.Variables.ClaimInfo@5774994a</declarations>
<factHandleIds>1</factHandleIds>
</org.drools.core.audit.event.ActivationLogEvent>
<org.drools.core.audit.event.ActivationLogEvent>
<type>4</type>
<activationId>checking primacy [1]</activationId>
<rule>checking primacy</rule>
<declarations>$a2=com.rsrit.cob.Variables.ClaimInfo@5774994a</declarations>
<factHandleIds>1</factHandleIds>
</org.drools.core.audit.event.ActivationLogEvent>
<org.drools.core.audit.event.ActivationLogEvent>
<type>6</type>
<activationId>checking primacy [1]</activationId>
<rule>checking primacy</rule>
<declarations>$a2=com.rsrit.cob.Variables.ClaimInfo@5774994a</declarations>
<factHandleIds>1</factHandleIds>
</org.drools.core.audit.event.ActivationLogEvent>
<org.drools.core.audit.event.ActivationLogEvent>
<type>7</type>
<activationId>checking primacy [1]</activationId>
<rule>checking primacy</rule>
<declarations>$a2=com.rsrit.cob.Variables.ClaimInfo@5774994a</declarations>
<factHandleIds>1</factHandleIds>
</org.drools.core.audit.event.ActivationLogEvent>
<org.drools.core.audit.event.ActivationLogEvent>
<type>4</type>
<activationId>procedures [1, 1]</activationId>
<rule>procedures</rule>
<declarations>$a2=com.rsrit.cob.Variables.ClaimInfo@5774994a; $a3=com.rsrit.cob.Variables.ClaimInfo@5774994a</declarations>
<factHandleIds>1</factHandleIds>
</org.drools.core.audit.event.ActivationLogEvent>
<org.drools.core.audit.event.ActivationLogEvent>
<type>6</type>
<activationId>procedures [1, 1]</activationId>
<rule>procedures</rule>
<declarations>$a2=com.rsrit.cob.Variables.ClaimInfo@5774994a; $a3=com.rsrit.cob.Variables.ClaimInfo@5774994a</declarations>
<factHandleIds>1</factHandleIds>
</org.drools.core.audit.event.ActivationLogEvent>
<org.drools.core.audit.event.ActivationLogEvent>
<type>7</type>
<activationId>procedures [1, 1]</activationId>
<rule>procedures</rule>
<declarations>$a2=com.rsrit.cob.Variables.ClaimInfo@5774994a; $a3=com.rsrit.cob.Variables.ClaimInfo@5774994a</declarations>
<factHandleIds>1</factHandleIds>
</org.drools.core.audit.event.ActivationLogEvent>
<org.drools.core.audit.event.ActivationLogEvent>
<type>4</type>
<activationId>provider within country [1, 1, 1]</activationId>
<rule>provider within country</rule>
<declarations>$a2=com.rsrit.cob.Variables.ClaimInfo@5774994a; $a3=com.rsrit.cob.Variables.ClaimInfo@5774994a; $a4=com.rsrit.cob.Variables.ClaimInfo@5774994a</declarations>
<factHandleIds>1</factHandleIds>
</org.drools.core.audit.event.ActivationLogEvent>
<org.drools.core.audit.event.ActivationLogEvent>
<type>6</type>
<activationId>provider within country [1, 1, 1]</activationId>
<rule>provider within country</rule>
<declarations>$a2=com.rsrit.cob.Variables.ClaimInfo@5774994a; $a3=com.rsrit.cob.Variables.ClaimInfo@5774994a; $a4=com.rsrit.cob.Variables.ClaimInfo@5774994a</declarations>
<factHandleIds>1</factHandleIds>
</org.drools.core.audit.event.ActivationLogEvent>
<org.drools.core.audit.event.ActivationLogEvent>
<type>7</type>
<activationId>provider within country [1, 1, 1]</activationId>
<rule>provider within country</rule>
<declarations>$a2=com.rsrit.cob.Variables.ClaimInfo@5774994a; $a3=com.rsrit.cob.Variables.ClaimInfo@5774994a; $a4=com.rsrit.cob.Variables.ClaimInfo@5774994a</declarations>
<factHandleIds>1</factHandleIds>
</org.drools.core.audit.event.ActivationLogEvent>
<org.drools.core.audit.event.ActivationLogEvent>
<type>4</type>
<activationId>claim_line_item [1, 1, 1, 1]</activationId>
<rule>claim_line_item</rule>
<declarations>$a5=com.rsrit.cob.Variables.ClaimInfo@5774994a; $a2=com.rsrit.cob.Variables.ClaimInfo@5774994a; $a3=com.rsrit.cob.Variables.ClaimInfo@5774994a; $a4=com.rsrit.cob.Variables.ClaimInfo@5774994a</declarations>
<factHandleIds>1</factHandleIds>
</org.drools.core.audit.event.ActivationLogEvent>
<org.drools.core.audit.event.ActivationLogEvent>
<type>6</type>
<activationId>claim_line_item [1, 1, 1, 1]</activationId>
<rule>claim_line_item</rule>
<declarations>$a5=com.rsrit.cob.Variables.ClaimInfo@5774994a; $a2=com.rsrit.cob.Variables.ClaimInfo@5774994a; $a3=com.rsrit.cob.Variables.ClaimInfo@5774994a; $a4=com.rsrit.cob.Variables.ClaimInfo@5774994a</declarations>
<factHandleIds>1</factHandleIds>
</org.drools.core.audit.event.ActivationLogEvent>
<org.drools.core.audit.event.ActivationLogEvent>
<type>7</type>
<activationId>claim_line_item [1, 1, 1, 1]</activationId>
<rule>claim_line_item</rule>
<declarations>$a5=com.rsrit.cob.Variables.ClaimInfo@5774994a; $a2=com.rsrit.cob.Variables.ClaimInfo@5774994a; $a3=com.rsrit.cob.Variables.ClaimInfo@5774994a; $a4=com.rsrit.cob.Variables.ClaimInfo@5774994a</declarations>
<factHandleIds>1</factHandleIds>
</org.drools.core.audit.event.ActivationLogEvent>
<org.drools.core.audit.event.ActivationLogEvent>
<type>4</type>
<activationId>claim_line_item_part_type_B [1, 1, 1, 1, 1]</activationId>
<rule>claim_line_item_part_type_B</rule>
<declarations>$a5=com.rsrit.cob.Variables.ClaimInfo@5774994a; $a7=com.rsrit.cob.Variables.ClaimInfo@5774994a; $a2=com.rsrit.cob.Variables.ClaimInfo@5774994a; $a3=com.rsrit.cob.Variables.ClaimInfo@5774994a; $a4=com.rsrit.cob.Variables.ClaimInfo@5774994a</declarations>
<factHandleIds>1</factHandleIds>
</org.drools.core.audit.event.ActivationLogEvent>
<org.drools.core.audit.event.ActivationLogEvent>
<type>6</type>
<activationId>claim_line_item_part_type_B [1, 1, 1, 1, 1]</activationId>
<rule>claim_line_item_part_type_B</rule>
<declarations>$a5=com.rsrit.cob.Variables.ClaimInfo@5774994a; $a7=com.rsrit.cob.Variables.ClaimInfo@5774994a; $a2=com.rsrit.cob.Variables.ClaimInfo@5774994a; $a3=com.rsrit.cob.Variables.ClaimInfo@5774994a; $a4=com.rsrit.cob.Variables.ClaimInfo@5774994a</declarations>
<factHandleIds>1</factHandleIds>
</org.drools.core.audit.event.ActivationLogEvent>
<org.drools.core.audit.event.ActivationLogEvent>
<type>7</type>
<activationId>claim_line_item_part_type_B [1, 1, 1, 1, 1]</activationId>
<rule>claim_line_item_part_type_B</rule>
<declarations>$a5=com.rsrit.cob.Variables.ClaimInfo@5774994a; $a7=com.rsrit.cob.Variables.ClaimInfo@5774994a; $a2=com.rsrit.cob.Variables.ClaimInfo@5774994a; $a3=com.rsrit.cob.Variables.ClaimInfo@5774994a; $a4=com.rsrit.cob.Variables.ClaimInfo@5774994a</declarations>
<factHandleIds>1</factHandleIds>
</org.drools.core.audit.event.ActivationLogEvent>
<org.drools.core.audit.event.ActivationLogEvent>
<type>4</type>
<activationId>event_name_phase1_b [1, 1, 1, 1, 1, 1]</activationId>
<rule>event_name_phase1_b</rule>
<declarations>$a5=com.rsrit.cob.Variables.ClaimInfo@5774994a; $a7=com.rsrit.cob.Variables.ClaimInfo@5774994a; $a2=com.rsrit.cob.Variables.ClaimInfo@5774994a; $a10=com.rsrit.cob.Variables.ClaimInfo@5774994a; $a3=com.rsrit.cob.Variables.ClaimInfo@5774994a; $a4=com.rsrit.cob.Variables.ClaimInfo@5774994a</declarations>
<factHandleIds>1</factHandleIds>
</org.drools.core.audit.event.ActivationLogEvent>
<org.drools.core.audit.event.ActivationLogEvent>
<type>6</type>
<activationId>event_name_phase1_b [1, 1, 1, 1, 1, 1]</activationId>
<rule>event_name_phase1_b</rule>
<declarations>$a5=com.rsrit.cob.Variables.ClaimInfo@5774994a; $a7=com.rsrit.cob.Variables.ClaimInfo@5774994a; $a2=com.rsrit.cob.Variables.ClaimInfo@5774994a; $a10=com.rsrit.cob.Variables.ClaimInfo@5774994a; $a3=com.rsrit.cob.Variables.ClaimInfo@5774994a; $a4=com.rsrit.cob.Variables.ClaimInfo@5774994a</declarations>
<factHandleIds>1</factHandleIds>
</org.drools.core.audit.event.ActivationLogEvent>
<org.drools.core.audit.event.ActivationLogEvent>
<type>7</type>
<activationId>event_name_phase1_b [1, 1, 1, 1, 1, 1]</activationId>
<rule>event_name_phase1_b</rule>
<declarations>$a5=com.rsrit.cob.Variables.ClaimInfo@5774994a; $a7=com.rsrit.cob.Variables.ClaimInfo@5774994a; $a2=com.rsrit.cob.Variables.ClaimInfo@5774994a; $a10=com.rsrit.cob.Variables.ClaimInfo@5774994a; $a3=com.rsrit.cob.Variables.ClaimInfo@5774994a; $a4=com.rsrit.cob.Variables.ClaimInfo@5774994a</declarations>
<factHandleIds>1</factHandleIds>
</org.drools.core.audit.event.ActivationLogEvent>
<org.drools.core.audit.event.ActivationLogEvent>
<type>4</type>
<activationId>event_dates_B [1, 1, 1, 1, 1, 1, 1, 2]</activationId>
<rule>event_dates_B</rule>
<declarations>$a2=com.rsrit.cob.Variables.ClaimInfo@5774994a; $a3=com.rsrit.cob.Variables.ClaimInfo@5774994a; $a4=com.rsrit.cob.Variables.ClaimInfo@5774994a; $a5=com.rsrit.cob.Variables.ClaimInfo@5774994a; $a7=com.rsrit.cob.Variables.ClaimInfo@5774994a; $a10=com.rsrit.cob.Variables.ClaimInfo@5774994a; $a13=com.rsrit.cob.Variables.ClaimInfo@5774994a</declarations>
<factHandleIds>1,2</factHandleIds>
</org.drools.core.audit.event.ActivationLogEvent>
<org.drools.core.audit.event.ActivationLogEvent>
<type>6</type>
<activationId>event_dates_B [1, 1, 1, 1, 1, 1, 1, 2]</activationId>
<rule>event_dates_B</rule>
<declarations>$a2=com.rsrit.cob.Variables.ClaimInfo@5774994a; $a3=com.rsrit.cob.Variables.ClaimInfo@5774994a; $a4=com.rsrit.cob.Variables.ClaimInfo@5774994a; $a5=com.rsrit.cob.Variables.ClaimInfo@5774994a; $a7=com.rsrit.cob.Variables.ClaimInfo@5774994a; $a10=com.rsrit.cob.Variables.ClaimInfo@5774994a; $a13=com.rsrit.cob.Variables.ClaimInfo@5774994a</declarations>
<factHandleIds>1,2</factHandleIds>
</org.drools.core.audit.event.ActivationLogEvent>
<org.drools.core.audit.event.ActivationLogEvent>
<type>7</type>
<activationId>event_dates_B [1, 1, 1, 1, 1, 1, 1, 2]</activationId>
<rule>event_dates_B</rule>
<declarations>$a2=com.rsrit.cob.Variables.ClaimInfo@5774994a; $a3=com.rsrit.cob.Variables.ClaimInfo@5774994a; $a4=com.rsrit.cob.Variables.ClaimInfo@5774994a; $a5=com.rsrit.cob.Variables.ClaimInfo@5774994a; $a7=com.rsrit.cob.Variables.ClaimInfo@5774994a; $a10=com.rsrit.cob.Variables.ClaimInfo@5774994a; $a13=com.rsrit.cob.Variables.ClaimInfo@5774994a</declarations>
<factHandleIds>1,2</factHandleIds>
</org.drools.core.audit.event.ActivationLogEvent>
<org.drools.core.audit.event.ActivationLogEvent>
<type>4</type>
<activationId>SPECIAL_PARTB_CASE [1, 1, 1, 1, 1, 1, 1, 2, 1]</activationId>
<rule>SPECIAL_PARTB_CASE</rule>
<declarations>$a15=com.rsrit.cob.Variables.ClaimInfo@5774994a; $a2=com.rsrit.cob.Variables.ClaimInfo@5774994a; $a3=com.rsrit.cob.Variables.ClaimInfo@5774994a; $a4=com.rsrit.cob.Variables.ClaimInfo@5774994a; $a5=com.rsrit.cob.Variables.ClaimInfo@5774994a; $a7=com.rsrit.cob.Variables.ClaimInfo@5774994a; $a10=com.rsrit.cob.Variables.ClaimInfo@5774994a; $a13=com.rsrit.cob.Variables.ClaimInfo@5774994a</declarations>
<factHandleIds>1,2</factHandleIds>
</org.drools.core.audit.event.ActivationLogEvent>
<org.drools.core.audit.event.ActivationLogEvent>
<type>6</type>
<activationId>SPECIAL_PARTB_CASE [1, 1, 1, 1, 1, 1, 1, 2, 1]</activationId>
<rule>SPECIAL_PARTB_CASE</rule>
<declarations>$a15=com.rsrit.cob.Variables.ClaimInfo@5774994a; $a2=com.rsrit.cob.Variables.ClaimInfo@5774994a; $a3=com.rsrit.cob.Variables.ClaimInfo@5774994a; $a4=com.rsrit.cob.Variables.ClaimInfo@5774994a; $a5=com.rsrit.cob.Variables.ClaimInfo@5774994a; $a7=com.rsrit.cob.Variables.ClaimInfo@5774994a; $a10=com.rsrit.cob.Variables.ClaimInfo@5774994a; $a13=com.rsrit.cob.Variables.ClaimInfo@5774994a</declarations>
<factHandleIds>1,2</factHandleIds>
</org.drools.core.audit.event.ActivationLogEvent>
<org.drools.core.audit.event.ObjectLogEvent>
<type>2</type>
<factId>1</factId>
<objectToString>com.rsrit.cob.Variables.ClaimInfo@5774994a</objectToString>
</org.drools.core.audit.event.ObjectLogEvent>
<org.drools.core.audit.event.ObjectLogEvent>
<type>2</type>
<factId>1</factId>
<objectToString>com.rsrit.cob.Variables.ClaimInfo@5774994a</objectToString>
</org.drools.core.audit.event.ObjectLogEvent>
<org.drools.core.audit.event.ActivationLogEvent>
<type>7</type>
<activationId>SPECIAL_PARTB_CASE [1, 1, 1, 1, 1, 1, 1, 2, 1]</activationId>
<rule>SPECIAL_PARTB_CASE</rule>
<declarations>$a15=com.rsrit.cob.Variables.ClaimInfo@5774994a; $a2=com.rsrit.cob.Variables.ClaimInfo@5774994a; $a3=com.rsrit.cob.Variables.ClaimInfo@5774994a; $a4=com.rsrit.cob.Variables.ClaimInfo@5774994a; $a5=com.rsrit.cob.Variables.ClaimInfo@5774994a; $a7=com.rsrit.cob.Variables.ClaimInfo@5774994a; $a10=com.rsrit.cob.Variables.ClaimInfo@5774994a; $a13=com.rsrit.cob.Variables.ClaimInfo@5774994a</declarations>
<factHandleIds>1,2</factHandleIds>
</org.drools.core.audit.event.ActivationLogEvent>
</events>
</org.drools.core.audit.W
orkingMemoryLog>
Мои правила. Код исполнителя
package com.rsrit.cob.drools;
import java.io.BufferedWriter;
import java.io.OutputStreamWriter;
import java.io.Serializable;
import java.util.ArrayList;
import javax.validation.constraints.AssertTrue;
import org.kie.api.KieServices;
import org.kie.api.logger.KieRuntimeLogger;
import org.kie.api.runtime.StatelessKieSession;
import org.kie.internal.command.CommandFactory;
import org.kie.api.runtime.rule.EntryPoint;
import org.kie.api.runtime.rule.FactHandle;
import org.kie.api.command.*;
import org.kie.*;
import java.util.*;
import com.rsrit.cob.Variables.ClaimInfo;
import com.rsrit.cob.drools.KieSessionFactory;
@SuppressWarnings("serial")
public class RulesExecutor implements Serializable{
public static BufferedWriter log = new BufferedWriter(new OutputStreamWriter(System.out));
@SuppressWarnings("unchecked")
public ClaimInfo evalRules(ClaimInfo claimObj,String ruleFileLoc){
if (ruleFileLoc != null){
StatelessKieSession ksession = KieSessionFactory.getKieSession(ruleFileLoc);
KieRuntimeLogger logger = KieServices.Factory.get().getLoggers().newFileLogger(ksession,"C://Users/katuk/eclipse-workspace/COB");
String claim_Id = claimObj.getClm_id();
int claim_Id_int = Integer.parseInt(claim_Id);
KieSessionFactory.globalStringK = KieSessionFactory.globalStringK + "\t" +claim_Id;
ksession.execute("globalStringK = "+KieSessionFactory.globalStringK);
ksession.setGlobal(KieSessionFactory.globalStringK, claim_Id);
ksession.execute("claim ID = "+claim_Id);
System.out.println("claim id = "+claim_Id);
ksession.execute(CommandFactory.newInsert(claimObj));
logger.close();
}else{
try{
log.write("Rules File Location is Invalid or Null\n");
log.flush();
}catch(Exception e){
e.printStackTrace();
}
}
return claimObj;
}
}