Re: [rules-users] Is my use case suuported in Drools?
by Elran Dvir
I neglected to mention I am checking different types of CEP engines to embed inside our java application.
So my question is about Drools Fusion syntax and features.
Thanks.
From: Elran Dvir
Sent: Sunday, August 11, 2013 10:57 AM
To: rules-users(a)lists.jboss.org
Subject: Is my use case suuported in Drools?
Hi all,
I am new to drools and I'm trying to understand whether the following use case is supported - any help on the following will be greatly appreciated:
I would like to create a new event based on multiple events (all of the same type meeting a set of conditions) occurring over a given period of time T1.
For each combination of values for fieldA and fieldB, a new group of event candidates should be opened (fieldA and fieldB are group by fields. Each combination of values of these fields, should be treated separately).
The event should be created when at least X events occurred over the period. Count the events based on unique values of fieldC and fieldD (for a given combination of fieldA and fieldB, if you notice an event with already existing values of the combination of fieldC and fieldD, it should not be counted).
If all conditions described above are met, create the desired new event. The new event will stay open for duration of T2, and update will be sent for it every T3.
Aside from the above, I need an aggregation function (besides count) of "collect" : in the new event the value of fieldE will be the collection of (preferably distinct) values of fieldE in originating events.
Example:
Port scan event - the basic event is connection. For each combination of source_ip and destination_ip (group by fields), detect a port scan event if over a minute (T1) there more than 20 (X) events with different ports (unique field).
The event will stay open for 10 minutes (T2) and an update will be sent every 1 minute (T3). Every update will contain the count of events, source_ip, destination_ip and collection of services.
Thanks a lot.
12 years, 8 months
calling kbuilder API from jsp and servlet
by ashish6276
Hi,
we are trying to call drools api from servlet by using
KnowledgeBuilderFactory and proving drl path and creating knowledge base and
session but when i am gonna fireRule it is giving me compile time error.
I am pasting the log below.
Aug 9, 2013 10:17:11 AM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet dispatcher threw exception
java.lang.NoClassDefFoundError: org/drools/builder/KnowledgeBuilderFactory
at
com.maxmechanics.controller.MMController.fireRulesAndGetResponse(MMController.java:467)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at
org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176)
at
org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:439)
at
org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:427)
at
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:925)
at
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856)
at
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:915)
at
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:811)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
at
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:796)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:852)
at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Unknown Source)
this error is coming while initializing knowledgefactory.
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory
.newKnowledgeBuilder();
--
View this message in context: http://drools.46999.n3.nabble.com/calling-kbuilder-API-from-jsp-and-servl...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 8 months
Guvnor in Reselliency environment : Assets stored in DB not visible in Secondary server
by Zahid Ahmed
I am working in Drools-Guvnor-5.5.0.Final version and have configured repository.xml to save all assets + indexes in Oracle 11 database.
I am deploying Guvnor in a resilient environment which has two servers. Guvnor deployed in both the servers is pointing to the same database.
Step 1
For this I generated the repository.xml from the administration panel of Guvnor and replaced in both primary and secondary Guvnor instance. And when I started the server and imported assets into primary guvnor, I was able to see the following tables in database,
1. FS_FSENTRY;
2. FS_WS_DEFAULT_FSENTRY;
3. PM_WS_DEFAULT_FSENTRY;
4. PM_WS_DEFAULT_BINVAL;
5. PM_WS_DEFAULT_BUNDLE;
6. PM_WS_DEFAULT_REFS;
7. PM_WS_DEFAULT_NAMES;
8. REPOSITORY_FS_FSENTRY;
9. VERSIONING_FS_FSENTRY;
10. VERSIONING_PM_BINVAL;
11. VERSIONING_PM_BUNDLE;
12. VERSIONING_PM_NAMES;
13. VERSIONING_PM_REFS;
I also configured workspace.xml files in
1. jboss-eap-6.0/bin/repository/workspaces/default
2. jboss-eap-6.0/bin/repository/workspaces/security
Step 2
Now started secondary guvnor, configured similar to primary Guvnor. But secondary server did not displayed the packages and assets from DB. Instead asked me to install sample packages.
Step 3
I configured DataStore in repository.xml. Restarted primary Guvnor server and found one more table is created in database with the assets init.
Table name : DS_DATASTORE
Step 4
Configured secondary Guvnor with DataStore and restarted it. Now I could see the packages of primary Guvnor, But the assets in packages were not available.
I am attaching the repository.xml file from both the servers.
Thanks and Best Regards,
Zahid Ahmed
Senior Software Engineer | Emirates Group IT
P.O. Box 686 | Dubai, United Arab Emirates
T +971 4 245 2551| M +971 55 124 9171
12 years, 8 months
WorkingMemoryListener & Declared Types
by droolster
Hello,
Please can the community help me.
I am attaching a WorkingMemoryListener to a session. In my DRL file, I have
a number of declared types for which I want to "watch" when the process is
running. How can I implement a "toString()" method in the DRL file for a
declared type? I have detailed the structure of my code below to make it
clear what I am trying to do:
DRL FILE
--------
declare Foo
low : double
high : double
score : int
end
Java Code
----------
ksession.addEventListener(new WorkingMemoryEventListener()
{
@Override
public void objectInserted(ObjectInsertedEvent event) {
System.out.println(*"Inserted: " + event.toString()*);
/*// Here I would like to print out the data in the
type Foo in a specific format.*/
}
@Override
public void objectUpdated(ObjectUpdatedEvent event) {
System.out.println("Updated");
}
@Override
public void objectRetracted(ObjectRetractedEvent event) {
System.out.println("Retracted");
}
});
Thanks in advance for your help.
--
View this message in context: http://drools.46999.n3.nabble.com/WorkingMemoryListener-Declared-Types-tp...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 8 months
Guvnor - Unable to fire rules from standalone java
by rganesh84
I am new to drools and even more new to Guvnor.
I have a below code with simple rules (just 2) which doesn't work as
expected, any help would be greatly appreciated.
I attempted to copy the contents of guvnor generated drl file to a local drl
file and tested with drools expert, it works well.
For the below program,
Drools expert (minor changes to java program -
ResourceFactory.newClassPathResource("test.drl")) show the s.o.p (after
firing 1st rule) and prints 90000 (after firing 2nd rule) as expected.
Drools guvnor prints salary as 0.0.
Not sure what is going wrong while integrating with Guvnor, doesn't work as
expected. need help!
[code]
/* Java main method. */
public static void main(String as[]){
KnowledgeBase kbase = readKnowledgeBase1();
StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
Employee employee = new Employee();
employee.setName("David");
employee.setExperience(1);
ksession.insert(employee);
ksession.fireAllRules();
System.out.println(employee.getSalary());
}
private static KnowledgeBase readKnowledgeBase() throws Exception {
KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
KnowledgeAgentConfiguration kaconf = KnowledgeAgentFactory
.newKnowledgeAgentConfiguration();
kaconf.setProperty("drools.agent.scanDirectories", "false");
KnowledgeAgent kagent = KnowledgeAgentFactory.newKnowledgeAgent("test
agent", kaconf);
kagent.applyChangeSet(ResourceFactory.newClassPathResource("change-set.xml"));
return kbase;
}
/* Change set xml contents: */
<change-set xmlns='http://drools.org/drools-5.0/change-set'
xmlns:xs='http://www.w3.org/2001/XMLSchema-instance'
xs:schemaLocation='http://drools.org/drools-5.0/change-set
http://anonsvn.jboss.org/repos/labs/labs/jbossrules/trunk/drools-api/src/...'
>
<add>
<resource
source='http://localhost:8080/guvnor-5.5.0.Final-tomcat-6.0/org.drools.guvnor.Guv...'
type='DRL'
basicAuthentication="enabled" username="admin" password="admin"/>
</add>
</change-set>
/* Rule file as downloaded from the below link
*
http://localhost:8080/guvnor-5.5.0.Final-tomcat-6.0/rest/packages/Employe...
*/
package EmployeeDetails
import com.sample.Employee
rule "Rule 1"
no-loop true
dialect "mvel"
when
Employee( experience < 3 )
then
System.out.println("User does not have enough experience");
end
rule "Rule 2"
no-loop true
dialect "mvel"
when
emp : Employee( name == "David" )
then
emp.setSalary( 90000 );
update( emp );
end
[/code]
--
View this message in context: http://drools.46999.n3.nabble.com/Guvnor-Unable-to-fire-rules-from-standa...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 8 months
'modify' and 'update' do not work in rules
by mukha
Hi all,
I am using /OptaPlanner/ ver. *6.0.Beta3*.
And I try to call one rule for preparation purposes. I try 3 options:
*1)* By defining additional problem facts /EmployeeAssignment/ for each
employee. Here I am trying to change only its property like this:
/rule "First rule"
salience 1
when
$employeeAssignment : EmployeeAssignment($employee : employee)
accumulate
(
$request : Request(assignedTo == $employee, $points : points),
$assignedPoints : sum($points)
)
then
$employeeAssignment.setAssignedPoints($assignedPoints.intValue());
update($employeeAssignment);
end/
That variant compiles well, but did not even start (e.g. when I try
benchmark it stops on "Warming up started" message and did not do anything).
*2)* Same with /modify($employeeAssignment) {...}/
*3)* The last one is with /insertLogical/. I did not use here
/EmployeeAssignment/ as additional problem fatcs, but just use:
/then
insertLogical(new EmployeeAssignment($employee, $assignedRequests,
$assignedPoints.intValue()));
end/
It works, but with low performance (examples were simplified).
Can you tell me what can be wrong with the 1) and 2) ?
Thank you for your time!
--
View this message in context: http://drools.46999.n3.nabble.com/modify-and-update-do-not-work-in-rules-...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 8 months
Optaplanner, loading drl from filesystm not off classpath
by meganwoods
Hi,
Is it possible to load drl files from the filesystem without them being on
the classpath.
I can create an XML solver factory using a stream from the constructor but
the loading of any DRL files appears to require those drl files to be on the
class path.
Looking at the private XmlBuildFactory.buildKieBase on line 301 it uses
getClass().getResourceAsStream()
I was wondering if there was another strategy I could use to load DRL's off
the file system as opposed to off the classpath.
Cheers Megan Woods
--
View this message in context: http://drools.46999.n3.nabble.com/Optaplanner-loading-drl-from-filesystm-...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 8 months