Disable JIT in Drools 6.2 with Java 8

最后都变了- 提交于 2019-12-08 16:41:34

Well after doing a lot of debugging we found that one of our rule was causing the problem. But the rule was valid and we could not discard it.

Finally I found a way to disable the JIT compiler which solved our problem and the error was gone. This is a different solution from what was mentioned by Esteban Aliverti. The one mentioned below worked for our case and would work for most of the cases.

I used the following way to disable the JIT compiler:

KieBaseConfiguration kbConfig = KieServices.Factory.get().newKieBaseConfiguration();
kbConfig.setOption(ConstraintJittingThresholdOption.get(-1));

The actual explanation is as follows:

0 -> force immediate synchronous jitting (it's adviced to use this only for testing purposes).
-1 (or any other negative number) -> disable jitting
Default value is 20.

So once we set the ConstraintJittingThresholdOption as -1, it disables the JIT compiler.

The way I found in Drools 6.4 (maybe it also works in 6.2) to disable the JIT compilation of MVEL expressions is to set its threshold to 0. The JIT threshold basically tells Drools how many times an expression has to be evaluated before it gets JIT compiled. A threshold of 0 means 'never JIT compile the expressions'.

The way I found to do this was by using the org.kie.internal.conf.ConstraintJittingThresholdOption KieBaseConfiguration in my KieBases:

KieHelper helper = new KieHelper();
helper.addResource(ResourceFactory.newClassPathResource("rules/jit/jit-sample.drl"));

KieSession ksession = helper.build(ConstraintJittingThresholdOption.get(0)).newKieSession();

I couldn't find a way to do it from the kmodule.xml file though.

I didn't try to use -Ddrools.jittingThreshold=0 either, but I think it should also work.

NOTE: The problem with disabling the JIT compilation of the expressions in Drools is that it affects the entire KieBase. I would suggest you to investigate a little bit further what the exception you are getting is all about.


Edit:

Satyam Roy is right. The propper value to use for ConstraintJittingThresholdOption or -Ddrools.jittingThreshold in order to completely disable the JIT compilation is a negative number and not 0.

Hope it helps,

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!