简体   繁体   English

Drools:如何设置多线程(multithreadEvaluation)7.34.0 -Java Maven Spring

[英]Drools: How to set multithreading (multithreadEvaluation) 7.34.0 -Java Maven Spring

I see that multithreadEvaluation is set to false by default.我看到 multithreadEvaluation 默认设置为 false 。 I have a simple Maven Spring Drools implementation using spreadsheet decision tables.我有一个使用电子表格决策表的简单 Maven Spring Drools 实现。

There's not much to it as it's basically a standard installation.它没有太多内容,因为它基本上是标准安装。 I have a restful API and when using jmeter to POST to our endpoint, the entity is populated and then we fire all rules on it.我有一个安静的 API 并且当使用 jmeter POST 到我们的端点时,实体被填充,然后我们触发它的所有规则。 When using multiple threads in jmeter, I can clearly see that multithreading is not working.在 jmeter 中使用多线程时,我可以清楚地看到多线程不起作用。

From the documentation:从文档中:

You can enable multithreaded evaluation using one of the following options: Enable the multithreaded evaluation system property: drools.multithreadEvaluation=true您可以使用以下选项之一启用多线程评估: 启用多线程评估系统属性: drools.multithreadEvaluation=true

Enable multithreaded evaluation while creating the KIE base programmatically:在以编程方式创建 KIE 基础时启用多线程评估:

 KieServices ks = KieServices.Factory.get(); KieBaseConfiguration kieBaseConf = ks.newKieBaseConfiguration(); kieBaseConf.setOption(MultithreadEvaluationOption.YES); KieBase kieBase = kieContainer.newKieBase(kieBaseConf);

Tried adding drools.multithreadedEvaluation=true to application.properties.尝试将drools.multithreadedEvaluation=true添加到 application.properties。 Didn't resolve the issue.没有解决问题。

Tried the second method within the kieSession() @Bean, but the kieBase is not used and it didn't resolve the issue.尝试了kieSession() @Bean 中的第二种方法,但没有使用 kieBase,也没有解决问题。 Currently unsure if simply instantiating the KieBase is sufficient.目前不确定是否仅仅实例化 KieBase 就足够了。 Where should this go?这个 go 应该在哪里? The method returns kContainer.newKieSession() so not sure how to tell if the kieBaseConf.setOption(MultithreadEvaluationOption.YES) actually did anything.该方法返回 kContainer.newKieSession() 所以不确定如何判断 kieBaseConf.setOption(MultithreadEvaluationOption.YES) 是否真的做了任何事情。

Tried and failed to create a new kieSession prior to fireAllRules.尝试在 fireAllRules 之前创建新的 kieSession 失败。 That service is @Autowired to a kieSession @Bean.该服务是 @Autowired 到 kieSession @Bean。

First time working with literally this entire tech stack so thank you for taking it slow.第一次使用整个技术堆栈,所以感谢您慢慢来。

TL;DR Need step by step instructions how to set drools.multithreadEvaluation to true. TL;DR 需要逐步说明如何将 drools.multithreadEvaluation 设置为 true。

As per documentation Drools expects the System property to be set, while you are setting it in application.properties , which I assume is Spring-related?根据文档 Drools 期望设置System属性,而您在application.properties中设置它,我认为它与 Spring 相关? Try setting it one of the following ways:尝试通过以下方式之一进行设置:

  1. When launching your application add "-Ddrools.multithreadEvaluation" to the command line, eg:启动应用程序时,将“-Ddrools.multithreadEvaluation”添加到命令行,例如:

    java -Ddrools.multithreadEvaluation <the rest of parameters>

  2. Or set it programmatically on the application start-up early on initialization before any Drools classes are invoked:或者在调用任何 Drools 类之前的初始化早期以编程方式在应用程序启动时设置它:

    System.setProperty("drools.multithreadEvaluation", "true");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM