I have a lot of events log insert to ksession, and I need to find out the facts which trigered the specific rule.How can i get the relation ship between the facts which trigered the rule and the events log?
You can use drools keyword
import java.util.Arrays;
rule
when
...
then
System.out.println(Arrays.asList(drools.getTuple().toObjects()));
...
end
Related
I have an application I am trying to experiment with. The business rules I am trying to create are all related but it makes sense for me to group the logic by drl file. For example, I want to put information about customers in the customer.drl file. I want to put logic about the categories of product in the productCategory.drl file and purchases.drl. Finally, I'd like to have a fourth file summarizing my findings for a report.drl
I don't want to create entirely separate modules. I just want to split out the logic so that I can easily maintain the logic in the code. In effect, I'd like something like this:
src/main/resources/rules
customers.drl
purchases.drl
productCategory.drl
reports.drl
I want to be able to share the logic between the facts in a single KieSession, utilizing all the drl files. First, I want to insert customer facts, group them by demographics, then insert their purchase information and products purchased and categorize them. Finally, I want to aggegrate that data in a report by inserting the previously gathered facts to generate data from the reports.drl
Is the configuration, I'm showing a feasible way of doing it. I'm of course assuming that the KiesSession will pick all the drl files in the rules package if I use a classpath container.
Is this the right way?
Looking at the documentation, I can group related rules under the same package. It is one of the options available. So for my use case this works. According to the documentation, I can create a kmodule.xml, and indicate the package, use a classpath container and load the KieSession. If I use a default kmodule definition with no KieBase defined, it will use a default KieBase and load all the resources in the src/main/resources and its other subfolders and this works!
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 3 years ago.
Improve this question
org.springframework.dao.EmptyResultDataAccessException: Item 0 of 10 did not update any rows: I get this error when trying to update records in an ItemWriter using spring batch. Has anyone seen this error?
This isn't actually related to Spring Batch itself, rather than data access generally.
Please make sure that your db update/insert query is correct.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
What is the difference between DB2 sql codes -913 and -904 with an example?
An SQL code of -913 is UNSUCCESSFUL EXECUTION CAUSED BY DEADLOCK OR TIMEOUT. REASON CODE reason-code, TYPE OF RESOURCE resource-type, AND RESOURCE NAME resource-name
An SQL code of -904 is UNSUCCESSFUL EXECUTION CAUSED BY AN UNAVAILABLE RESOURCE. REASON reason-code, TYPE OF RESOURCE resource-type, AND RESOURCE NAME resource-name
A -913 is a deadlock, or two programs trying to get the same resource. The classic example is program 1 updating table B, then A; and program 2 updating table A, then B. Neither program can get to the second resource, so you have a deadlock. To prevent this, all of your programs must modify DB2 tables in the same order (A, then B).
A -904 is an unavailable resource. A dropped table or a locked table.
Both errors give you the name of the deadlocked resource or the unavailable resource.
-913 is SQL0913N Unsuccessful execution caused by deadlock or timeout.
-904 is SQL0904N Unsuccessful execution caused by an unavailable resource.
-904 is specific to DB2 for MVS.
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
We have SQL Server 2008 R2 Merge replication set up.
We have 20+ push subscriptions.
Once in a while I get the following error message during the sync:
Error messages: The merge process could not set the status of the
subscription correctly.
(Source: MSSQL_REPL, Error number: MSSQL_REPL-2147200963)
Could not find stored procedure 'dbo.sp_MScheckIsPubOfSub'.
(Source: MSSQLServer, Error number: 2812)
I have found the code for the mentioned SP & ran it against the subscriber database & everything worked fine.
My question is: why is this stored procedure getting deleted every now and then by itself ? And how I can troubleshoot this issue?
Please check for orphaned rows for deleted subscriptions in sysmergesubscriptions and delete them. For example, the subscriber that this is failing on may have duplicate entries in sysmergesubscriptions, one being orphaned from a previously deleted subscription.
This has been the cause of this error and solution for clients of mine in the past, ymmv. I hope this helps.
We use Drools with an interface where users can update / edit rules. Those rules are then stored (and versioned) in a database. Afterwards the rules are fetched again from database and added one by one in the following way:
for (Rule rule ...) {
knowledgeBuilder.add(ResourceFactory.newByteArrayResource(rule.getRuleContent().getBytes()), ResourceType.DRL);
if (kbuilder.hasErrors()) { throw Error... }
}
kbase = KnowledgeBaseFactory.newKnowledgeBase();
kbase.addKnowledgePackages(knowledgeBuilder.getKnowledgePackages());
We have several hundred rules and a rule checking throughput of also several hundred rules/second (on 2 nodes). With the number of rules increasing this KnowledgeBase update takes longer and longer (compiling all those rules) and during this time no rule can be checked. So the system stands still from the user point of view.
There seems to exist no possibility to refresh a rule selectively - is this correct? If yes, then how is the best way to handle such a situation? The first idea that comes to mind is using two KnowledgeBases in parallel...
The KnowledgeBase API has methods to remove rules/packages and also to add packages. So to accomplish this you could remove the rule you want to update and then insert the updated version into the knowledge base. If you have any statefull sessions who's dispose() method has not been called, than the changes to the KnowledgeBase should get pushed out to them as well.