How to use database in drool
by shawn
Hi~
My project requires to use drool interact with MySQL.
Like once the rule engine received a request, the engine will ask the
database to send some fact to the engine. The engine should give a result
after matching the fact with the rule (in rule engine).
Is there any tutorial for building connection between the engine to the
database?
I know Hibernate can do it, but for SQL is there any way to do it?
Regards,
Shawn
--
View this message in context: http://drools.46999.n3.nabble.com/How-to-use-database-in-drool-tp3737584p...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 10 months
time loading rules into knowledgebase giving different results when using mvel2-beta6 versus mvel2-drools4 jars
by vadlam
we have some interesting findings with loading rules PKG into knowledgebase
when using mvel2-beta6 jar versus mvel2-drools4 jar.
the PKG file was built in Guvnor 5.3.0.Final which uses mvel2-drools4 jar.
when we loaded this PKG file using Drools 5.3 jars and using mvel2-drools4
jar, we were getting OOM errors at around 1 GB .it would also take a very
long time to throw the error.
when we loaded this PKG file using Drools 5.3 jars and using mvel2-beta6
jar, we were able to load the package successfully in a lesser time and no
OOM errors at the same heap size.
Has anyone come across this issue?
is it advised/recommended to substitute mvel2-drools4 jar with mvel2-beta6
jar in our service code when loading the rules package as well as executing
the rules at runtime?
or, is there a specific reason for Guvnor 5..3 using mvel2-drools4 jar( such
as customized optimizations) instead of just mvel2 beta jars ?
--
View this message in context: http://drools.46999.n3.nabble.com/time-loading-rules-into-knowledgebase-g...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 10 months
Need Camel + drools (OSGI) integration help
by Alexander Filipchik
Hello all!
Don't know if it is right list to ask, but I'm trying to make drools +
camel running on Fuse (ServiceMix container).
I couldn't even install OSGI drools artifacts for 5.3.1 version (because of
weird dependency on drools.core Snapshot),
but did it with v5.2.1. I used:
mvel2/2.1.0,
org.drools/drools-core/5.2.1.Final, org.drools/drools-compiler/5.2.1.Final,
org.drools/knowledge-api/5.2.1.Final
and org.drools/drools-camel/5.2.1.Final.
All are installed and active. Part of log:
[ 162] [Active ] [ ] [ ] [ 60] Drools :: Compiler
(5.2.1.Final)
[ 163] [Active ] [ ] [ ] [ 60] mvel2 (2.1.0.drools4)
[ 164] [Active ] [ ] [ ] [ 60] Drools :: Core
(5.2.1.Final)
[ 165] [Active ] [ ] [ ] [ 60] Knowledge API
(5.2.1.Final)
[ 172] [Active ] [ ] [ ] [ 60]
mvn:org.drools/drools-camel/5.2.1.Final
Then I tried to add my own camel-drools router (I created OSGI bundle for
it). It depends on:
Import-Package:
org.apache.activemq,org.apache.activemq.camel.component,org.apache.activemq.pool,org.apache.camel;version="[2.8,3)",org.apache.camel.builder;version="[2.8,3)",org.apache.camel.component.jms;version="[2.8,3)",org.apache.camel.model;version="[2.8,3)",org.drools.camel.component,org.osgi.service.blueprint;version="[1.0.0,2.0.0)",org.springframework.transaction;version="[3,4)"
It tried to install it to a container but all I got -
Error executing command: Unresolved constraint in bundle com.betfair.drools
[170]: Unable to resolve 170.0: missing requirement [170.0] package;
(package=org.drools.camel.component)
I even tried to put drools-camel.jar with org.drools.camel.component in a
lib folder and add package to org.osgi.framework.system.packages.extra, but
got same result.
Do you have any idea, blog posts, samples which could help me?
I'm completely stuck.
Thanks,
Alex
12 years, 10 months
Migrating repository data from Drools 5.0 to 5.3Final
by jian zhi
Hi all,
I migrated the repository from Drools 5.0 to 5.3Final. The data was stored in Microsoft SQL Server database. I exported
the repository from Drools 5.0 Guvnor and imported it back to Drools 5.3 Guvnor. After that I found
that the order of the condition columns in the web-guided decision table were
changed, and also the values for the conditions were misplaced. See the rule sources
below.
Is this a bug, or I didn’t use the right way to migrate the drools data between two versions?
Thanks in advance,
Jian
Here is the source of the decision table in Drools 5.0:
#from row number: 1
rule "Row 1 test"
dialect
"mvel"
when
consumerAction
: ConsumerWorkActionFact( checkIfExist == "true" )
accountAction
: ConsumerAccountWorkActionFact( checkIfExist == "true" )
consumerTag
: ConsumerTagAssociationFact( hasAnyConsumerTagEM == "111" )
consumerAccount
: ConsumerAccountAssociationFact( hasAnyAccountClosed == "false" )
then
consumerAction.setChangeStrategy(
"222" );
consumerAction.setHoldConsumer(
"true" );
accountAction.setAssignConsumerAccountTags(
"333" );
end
Here is the source of the decision table in Drools 5.3:
#from row number: 1
2. | rule "Row 1 test"
3. | dialect
"mvel"
4. | when
5. | consumerAction : ConsumerWorkActionFact( checkIfExist ==
"true" )
6. | consumerTag : ConsumerTagAssociationFact( hasAnyConsumerTagEM ==
"false" )
7. | consumerAccount : ConsumerAccountAssociationFact( hasAnyAccountClosed ==
true )
8. | accountAction : ConsumerAccountWorkActionFact( checkIfExist ==
"111" )
9. | then
10. | consumerAction.setChangeStrategy( "222" );
11. | consumerAction.setHoldConsumer( "true" );
12. | accountAction.setAssignConsumerAccountTags(
"333" );
13. | end
12 years, 10 months
Problem with package names and declare section
by Joaquín Díaz Vélez
Hi guys,
we are currently working with Drools Fusion in order to build a
complex event processing solution. We've modelled our events using and
object (Event) and this object is shared with everyone that needs to
publish and event.
Our scenario goes this way
1) Our shared class, located in *ar.com.fluxit.Event*
2) An example of our cep rules declared in package *rules.flux*
package *rules.flux*
import *ar.com.fluxit.Event;*
declare *Event*
@role (event)
@expires(1m)
end
rule "hello world"
when
$event:Event( eventName == "Hello World") from entry-point "*rules.flux*
"
then
System.out.println("Hello world");
end
3) When we try to insert a *ar.com.fluxit.Event *as a fact in entry point
"rules.flux" Drools Fusion throws a NullPointerException. If you read
Drools Expert documentation (
http://docs.jboss.org/drools/release/5.2.0.Final/drools-expert-docs/html/...
-
Accessing Declared Types from the Application Code) you find this paragraph:
"The first important thing to realize is that a declared fact will belong
to the package where it was declared. So, for instance, in the example
below, Person will belong to the org.drools.examples package, and so the
fully qualified name of the generated class will be
org.drools.examples.Person."
When we change package declaration to *package ar.com.fluxit *everything
works like a charm. But in our cep scenario we need that our
ar.com.fluxit.Event object to be user by all rules declared in any package.
So, there goes the question. There is a workaround for this? This is a bug?
Any help would be very appreciated
Cheers
--
Joaquín Díaz Vélez
Flux IT SA
Calle 9 N° 865 - Paseo La Panadería - Planta Alta
La Plata - Buenos Aires - Argentina
Teléfono (+54) 221 553 2980 int 306
Móvil (+54) 9221 5863322
www.fluxit.com.ar
12 years, 10 months
Your suggestions for rules for pretty simple problem
by Jason Parekh
I'm new to constraint programming and Drools Planner. I've read through the
docs and built some rules that would probably get me to the right answer,
eventually :)
I was hoping to get your suggestions for better concrete rules.
The problem is I need to order items in a performance with the following
logical rules:
1) All items of the same category must appear together.
2) A performer can be in multiple items, but ideally there'd be at least
three items between any of her two items
The approaches I took are:
- For (1), count the number of transitions from one category to another.
Subtract this to the hard score.
- For (2), three separate rules, each of which assert that an item at
position i does not share performers with an item at position i+1, i+2 and
i+3 (one of these per rule). The number of shared performers would be
subtracted from the hard score.
The scoring and my choice for construction heuristic (FIRST_FIT) are just
naive selections. I haven't gotten to optimizing either of these -- just
wanted to check with you guys to make sure my rules are sane.
Thanks in advance,
jason
12 years, 10 months
5.3.0: combination of KnowledgeAgent and declare broken
by Wolfgang Laun
5.3.0 Final
Using a KnowledgeAgent to build a KnowledgeBase containing a DRL with the
declaration of a new type may result in some rules not firing at all.
The very same code compiled via KnowledgeBuilder API works perfectly
correct.
-W
12 years, 10 months
Truth maintenance and RHS variables
by Juanker Atina
Hi there,
I'm working on a rule that will alert me when there is no events from the
sensors for a while.
So, first idea was to use time window and matches in condition side, to
match all types of sensors, and then to print that something is wrong.
rule "Alert if there is no activity"
when
not StateEvent(itemName matches "door.*|presence.*|luminosity.*") over
window:time( 1m ) from entry-point "EventStream"
then
System.out.println("Alert: one sensor is not working");
end
First change was to add a timer, as truth maintenance will fire this rule
the first time, but not forever. So i add a timer to fire the rule every 20
seconds, for example.
rule "Alert if there is no activity"
timer (cron:0/20 * * * * ?)
when
not StateEvent(itemName matches "door.*|presence.*|luminosity.*") over
window:time( 1m ) from entry-point "EventStream"
then
System.out.println("Alert: one sensor is not working");
end
The second thing i want to achieve is to print what specific sensor is not
working, but i understand that as there is no StateEvent, i can't declare a
variable, for example.
rule "Alert if there is no activity"
timer (cron:0/20 * * * * ?)
when
not $event: StateEvent(itemName matches
"door.*|presence.*|luminosity.*") over window:time( 1m ) from entry-point
"EventStream"
then
System.out.println("Alert: one sensor is not working: " +
$event.getItemName());
So, do you know how can i know which sensor is not working? must i rewrite
the rule to achieve this? is this possible?
Thanks for your help.
end
12 years, 10 months
problem binding variable to map value
by Ming Fang
Below is a very simple rule that binds a variable to a map value...
rule "how many times is map.get() called?"
when
p:Parameter(
$value:tags[1]==1,
$value == 1,
$value != 2,
$value != null,
$value in ("1","2")
)
then
System.out.println("value=" + $value);
end
The problem is map.get() is called 6 times when executing this rule using a Stateless session.
To test this I implement a mock Map that the get(key) simply returns the key.
So in this example tags[1] return 1.
And in the get() I simply print a test message to see how many times it's been called.
Here is the sequence...
1x = tags[1]
2x = tags[1] == 1
3x = $value == 1
4x = $value != 2
5x = $value != null
and most surprisingly none for $value in ("1","2")
but
6x == System.out.println("value="+$value)
Is this a bug?
It's a huge problem for my application since the call to get() is expensive for my map implementation.
Thanks
--ming
12 years, 10 months