[英]How to set the AgendaGroup in StatelessKieSession drools
我有一個場景,我想在議程組中使用StatelessKieSession
。 該StatelessKieSession
不必組專注於特定的任何方法AgendaGroup
像正常KieSession
如下所示
KieContainer kContainer = ks.newKieContainer(kr.getDefaultReleaseId());
KieSession kSession = kContainer.newKieSession();
kSession.getAgenda().getAgendaGroup("us").setFocus();
如何使用StatelessKieSession
將焦點設置在特定的議程組上?
您可以使用 drl 文件中的drools.setFocus()方法在 StatelessKieSession 中設置議程組。 您必須明確做的一件事是在您的 Fact 對象中聲明一個變量,並為該變量分配議程組名稱。 示例規則如下:
rule "global" salience 100 when $rec : FactObject() then drools.setFocus($rec.getAgendaValue()); end
給這個規則一個高的顯着性值,以便它首先被執行。 檢查此博客。 他們正在做與您正在嘗試做的相同的事情。
對於 StatelessKieSession,您可以將 AgendGroup 和 Activation Group 設置為 Commands 的一部分
final List<Command> commands = newArrayList();
ClearActivationGroupCommand activationGroup = new ClearActivationGroupCommand("Test");
commands.add(activationGroup);
AgendaGroupSetFocusCommand agendaGroup = new AgendaGroupSetFocusCommand("Test");
commands.add(agendaGroup);
final FireAllRulesCommand fireAllRulesCommand = new FireAllRulesCommand();
commands.add(fireAllRulesCommand);
final BatchExecutionCommand command = CommandFactory.newBatchExecution(commands);
final StatelessKieSession session = kieContainer.newStatelessKieSession();
ExecutionResults executionResultsSupplier = session.execute(command);
result.setExecutionResult(executionResultsSupplier);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.