We sometimes see questions regarding Drools version upgrade. Most of those questions are about how to change the old API usage in Drools 5 or 6. In this article, I’m going to guide how to change your code to work with the latest Drools version (7.70.0.Final as of now).
If you are using old style APIs, it would be like this.
Since Drools 6, we have introduced new KIE APIs. So the old APIs are considered as internal APIs that are not recommended to use in user applications.
In Drools 7, technically, we can write in a similar style.
However, I write this example not to recommend you write in this style. Just to show a kind of bridge between old APIs and new KIE APIs.
In all the above examples, you build a package and give the package to a kbase.
In the new KIE APIs, the procedure is encapsulated in KieContainer.
Please have a look at the new KIE APIs style.
"Programmatically create a Kjar"
For details, please refer to the blog post.
If you have all rules in classpath (e.g. inside an application), "Basic DRL" would be the easiest example.
If you had rules in serialized PKGs, you would choose "Kjar and Runner" approach.
If you want to programmatically manage resource files, "Programmatically create a Kjar" would fit.
Some configuration classes might be moved to different packages or even removed. If you have any doubt, feel free to ask in community channels (https://groups.google.com/g/drools-usage , https://groups.google.com/g/drools-setup , https://kie.zulipchat.com/#narrow/stream/232677-drools).
DRL and XLS spreadsheets are basically backward compatible. So you can use rule assets in Drools 7.
But there is one caveat, "Property reactivity".
Property reactivity was introduced since Drools 5.4 but it was not enabled by default. However, it’s enabled by default since Drools 7. It means you may see that rules react differently when you upgrade the version. In that case, try to disable the feature and check if the different behaviour was caused by property reactivity.
If that is the case, you have 2 options.
A. Keep property reactivity disabled
B. Enable property reactivity and review your rules to meet property reactivity behaviour
Property reactivity a powerful feature which allows you to write rules naturally and also provide good performance. Please refer to this section for details.
Upgrading versions is a key maintenance action of open source software use. Please don’t hesitate!