very good !
And crystal clear ! Thanks a lot for the blog. It really helped me a lot.
Can you please post any complex examples with drools?
Actually i need to develop an application where the user should be able to create new rules during the run time.
I have a problem because the syntax of rules does’t seem to work for me.
In the ‘then’ section of a rule I have to use message getters and/or setters to get to the values instead of the property names.
Can you explain why this happens? Also is there any way to make drools work as you with the property names and not the getters/setters?
Comment by Marcin Lobocki — August 21, 2013 @ 12:24
Good article. However I’m facing a weird issue in Intellij when I run the MessageTest.java class. org.eclipse.jdt.internal.compiler.CompilationResult.getProblems()[Lorg/eclipse/jdt/core/compiler/CategorizedProblem;
Any idea how to resolve this?
Not from the top of my head. I would need to see your code and try for my self.
What happens when you remove test after test, possibly line by line, are you able to locate the offending statement? It is probably easier to understand the problem if you can locate the exact line that has the problem. It may even be obvious when you can trigger it at will.
I would like to suggest that you use a modern version of Maven. It will default to a Java level that supports annotations and static imports. Maven 2 is end of life 2014-02-18 according to http://maven.apache.org/docs/history.html.
You could also say that the source and target should be 1.7 in the compiler settings.
this result: Type: High value
Exception in thread “main” java.lang.AssertionError:
how does show 2 type, type Hello and type Hight value?
I really can’t say whats wrong. I can only see the Hamcrest error message that says that you didn’t get what you expected. I would have to assume that you have made a mistake when you copied the source code. I would suggest that you double check your source and possible find some error.
I don’t understand what you mean by “the workingMemory variable has overridden in createHighValue method”. The variable isn’t overridden in my version of the method. I am adding things into the workingMemory variable. It is a case of an output variable.
I executed my source code and got his output for the extended example:
Type: High value value: 42
Type: Hello value: 0
Since I haven’t seen your source I can only assume that you have made some kind of mistake when you copied the source code.
I would suggest that you create the extended example from scratch again. It is just a matter of creating a few files and copy some code. Should be pretty fast.
I like the post. It has helped get me up to speed quickly. When running it, I did run into an issue: java.lang.NoClassDefFoundError: com/google/protobuf/MessageOrBuilder. After adding dependency compile ‘com.google.protobuf:protobuf-java:2.6.1’ to my Gradle build, all worked fine.
i am looking for an API in drools to get the names of all the packages that i have created. This helps me to give user a flexibility of selecting the package from the list of packages in my application, so that only that particular package gets executed.
i didn’t find anything. Please help me on this
I have no idea how to do that out of the box with Drools. I would probably not even try finding it in Drools. I would probaly implement it myself by scanning the class path and use some clever heuristics to report back the relevant packages.
I haven’t done it so this is just an outline of my initial idea.
PackageBuilder packageBuilder = new PackageBuilder();
InputStream input = new URL(“http://localhost:8080/drools-guvnor/org.drools.guvnor.Guvnor/package/AutoAction/LATEST.drl”).openStream();
Reader reader = new InputStreamReader(input);
org.drools.core.rule.Package rulesPackage = packageBuilder.getPackage();
I am getting the null for packageBuilder.getPackage();
Do i need to pass any other information into PackageBuilder constructor the connect to my rules application?
Please let me know how can i achieve this.?
I don’t know what you need to change. You ask if you need to pass any other information into the constructor for PackageBuilder and that is possible. I think that Stackoverflow might be a better place to ask.