Drools-Fusion : Inserting an Event in to an "entry-point" stream in the RHS of a rule?? Pls help
by Chetan Mahadev
Hi
Can we insert an Event in the RHS part of a rule to an entry-point?
basically i am trying to do this. Pls let me know if this is possible? if
not any alternative approaches? Any example would be useful pls
declare TransactionEvent
@role( event )
end
$tmp : TestClass()
$tmp.message == "TRUE"
then
TransactionEvent ev1 = new TransactionEvent (); // This should be
inserted in to an entry-pont "Temporal Reasoning" stream
ev1.setMessage("Temporal Reasoning")
insert (ev1) to entry-point "Temporal Reasoning"
end
rule "Temporal Reasoning"
$tmp : TransactionEvent ( message== "Temporal Reasoning") from entry-point
"Temporal Reasoning"
then
System.out.println("Rule fired due to entry point ");
end
Regds
Chetan
13 years, 3 months
How to Access and Execute Rules from Database
by Ashish Soni
Hi All ,
I am able to configure oracle database in drools but now i am not able to
find how can i load rules from the DB and execute them , I gone through the
documentation but not able to get much information or might be i am missing
something.
If any one can provide me a example or some pointer ,hints then it would be
helpful.
Regards,
Ashish
13 years, 4 months
unable to determine operator for symbol [before]
by vladimiro
Hi all,
I'm building a KnowledgeBase with KnowledgeAgent and a precompiled
rule package. When the package contains a rule using temporal operators
such "after" or "before" I get the exception listed at the end of this
message.
I'm using the latest version of drools 5 and my runtime configuration
includes the following libraries:
* drools-core - the rule engine itself.
* drools-api
* mvel2-2.0.10
* joda-time-1.6
the rule causing such a behaviour is:
rule 'Test2'
dialect 'mvel'
when
u1:UserType( firstName=="UserA" )
lie:UserEventType( event=="Login", user.id==u1.id)
loe:UserEventType(event=="Logout", user.id==u1.id, this before lie)
then
Message msg = new Message();msg.setText("Test2
fired");driver.getMessages().add(msg);
end
java.lang.RuntimeException: KnowledgeAgent exception while trying to
deserialize KnowledgeDefinitionsPackage
at
org.drools.agent.impl.KnowledgeAgentImpl.rebuildResources(KnowledgeAgentImpl.java:418)
at
org.drools.agent.impl.KnowledgeAgentImpl.applyChangeSet(KnowledgeAgentImpl.java:120)
at
org.drools.agent.impl.KnowledgeAgentImpl.applyChangeSet(KnowledgeAgentImpl.java:109)
at
info.vladimiro.tesi.peservice.KnowledgeBaseService.<init>(KnowledgeBaseService.java:94)
at
info.vladimiro.tesi.peservice.KnowledgeBaseService.getInstance(KnowledgeBaseService.java:65)
at
info.vladimiro.tesi.peservice.PEListener$KBTask.run(PEListener.java:35)
at java.util.TimerThread.mainLoop(Timer.java:512)
at java.util.TimerThread.run(Timer.java:462)
Caused by: org.drools.RuntimeDroolsException: unable to determine
operator for symbol [before]
at
org.drools.base.evaluators.Operator.determineOperator(Operator.java:71)
at org.drools.base.evaluators.Operator.readResolve(Operator.java:106)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at
java.io.ObjectStreamClass.invokeReadResolve(ObjectStreamClass.java:1033)
at
java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1728)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1305)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:348)
at org.drools.base.BaseEvaluator.readExternal(BaseEvaluator.java:53)
at ...
Can someone help? Thanks in advance.
Vladimiro Corsi
13 years, 6 months
Drools 5.1 - exception when trying to use incremental KB updates.
by Stephen Mcgruer
Just moved to Drools 5.1, using a Guvnor package as the base for a
Knowledge Base with incremental updating enabled. Our resource is a
Guvnor PKG. We encounter the following error when a snapshot is made:
[2010:08:224 16:08:903:debug] KnowledgeAgent: Diffing: [UrlResource
path='http://localhost:1337/drools-guvnor/org.drools.guvnor.Guvnor/package/TEST...']
[2010:08:224 16:08:935:debug] BinaryResourceDiffProducerImpl:
Comparing [Rule name=Resource Null-Checker, agendaGroup=MAIN,
salience=0, no-loop=false] against [Rule name=Resource Null-Checker,
agendaGroup=MAIN, salience=0, no-loop=false]
Exception in thread "Thread-30" org.drools.RuntimeDroolsException:
java.lang.reflect.InvocationTargetException : [Rule name=Resource
Null-Checker, agendaGroup=MAIN, salience=0, no-loop=false]
at org.drools.core.util.ReflectiveVisitor.visit(ReflectiveVisitor.java:56)
at
org.drools.agent.impl.BinaryResourceDiffProducerImpl.diff(BinaryResourceDiffProducerImpl.java:63)
at
org.drools.agent.impl.KnowledgeAgentImpl.incrementalBuildResources(KnowledgeAgentImpl.java:785)
at
org.drools.agent.impl.KnowledgeAgentImpl.buildKnowledgeBase(KnowledgeAgentImpl.java:586)
at
org.drools.agent.impl.KnowledgeAgentImpl.applyChangeSet(KnowledgeAgentImpl.java:185)
at
org.drools.agent.impl.KnowledgeAgentImpl$ChangeSetNotificationDetector.run(KnowledgeAgentImpl.java:1106)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.reflect.InvocationTargetException
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.drools.core.util.ReflectiveVisitor.visit(ReflectiveVisitor.java:47)
... 6 more
Caused by: java.lang.RuntimeException: this MVELReturnValueExpression
must be compiled for equality
at
org.drools.base.mvel.MVELReturnValueExpression.equals(MVELReturnValueExpression.java:123)
at
org.drools.rule.ReturnValueRestriction.equals(ReturnValueRestriction.java:306)
at
org.drools.rule.ReturnValueConstraint.equals(ReturnValueConstraint.java:121)
at java.util.Arrays.equals(Unknown Source)
at org.drools.rule.OrConstraint.equals(OrConstraint.java:132)
at java.util.AbstractList.equals(Unknown Source)
at org.drools.rule.Pattern.equals(Pattern.java:317)
at org.drools.rule.GroupElement.equals(GroupElement.java:273)
at
org.drools.agent.impl.BinaryResourceDiffProducerImpl.compareRules(BinaryResourceDiffProducerImpl.java:258)
at
org.drools.agent.impl.BinaryResourceDiffProducerImpl.visitRule(BinaryResourceDiffProducerImpl.java:117)
... 11 more
The rule in question is quite straight-forward, works on the initial
load up and worked in 5.0.1 fine. It is not the rule that was just
changed. If I remove that rule, another is just substituted in its
place in the error message.
What might be causing this? If you need more information, please ask.
Stephen
--
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.
13 years, 6 months
KnowledgeAgent and Guvnor restart
by Gerret Hansper
Hello,
I have got an issue with the KnowledgeAgent that seems not to survive a Guvnor
restart. The scenario is as follows:
* We use Drools 5.0
* On our application server we create a KnowledgeAgent
applying a ChangeSet that points to a package binary on a separate Guvnor server
like so:
SystemEventListenerFactory.setSystemEventListener(new
SystemEventLogger());
ResourceFactory.getResourceChangeNotifierService().start();
ResourceFactory.getResourceChangeScannerService().start();
KnowledgeAgent agent =
KnowledgeAgentFactory.newKnowledgeAgent(workflowName);
agent.applyChangeSet(changeSet);
* Creating the kbase, registering globals and running sessions works fine.
* We shut down Guvnor (or the connection goes down, this was how we spotted the
problem) and restart it after a minute
* We then try to run sessions from the
same agent as above via
kagent.getKnowledgeBase().newStatefulKnowledgeSession();
which returns a ksession, but then setting a global we get
java.lang.RuntimeException: Unexpected global [log]
at
org.drools.common.AbstractWorkingMemory.setGlobal(AbstractWorkingMemory.java:5
50)
at
org.drools.impl.StatefulKnowledgeSessionImpl.setGlobal(StatefulKnowledgeSessio
nImpl.java:284)
>From the debugger I can see that indeed the ruleBase's globals map is empty. The
SystemEventLogger indicates that the KnowledgeAgent unsubscribes from its
resource when Guvnor is down and rebuilds its kbase. Also, it stops scanning the
resource and does not find it once Guvnor is up again. (See log snippet below).
Wouldn't it be better in these cases to keep the resource as is in memory and
try to rescan? I figure that as long as the resource is specified in the
changeSet it should be considered part of the kbase and not be removed if it
cannot be found.
For the time being, does anyone have a suggestion how to avoid these problems?
We could catch the RuntimeException and recreate the KnowledgeAgent, but perhaps
there is a better way?
Thanks, Gerret
-- SystemEventLog --
# Guvnor is up here
07:58:01,881 ResourceChangeScanner attempt to scan 1 resources
07:58:02,209 ResourceChangeScanner thread is waiting for 60
07:58:15,067 ResourceChangeScanner attempt to scan 1 resources
# Guvnor goes down here
07:58:16,738 ResourceChangeScanner removed resource=[UrlResource
path='http://localhost:7080/drools-
guvnor/org.drools.guvnor.Guvnor/package/com.foo.bar/LATEST']
07:58:16,738 ResourceChangeNotification received ChangeSet notification
07:58:16,738 ResourceChangeScanner thread is waiting for 60
07:58:16,738 ResourceChangeNotification processing ChangeSet
07:58:16,738 ResourceChangeNotification ChangeSet removed resource=[UrlResource
path='http://localhost:7080/drools-
guvnor/org.drools.guvnor.Guvnor/package/com.foo.bar/LATEST'] for
listener=org.drools.agent.impl.KnowledgeAgentImpl@1053d6d
07:58:16,738 ResourceChangeNotification ChangeSet removed resource=[UrlResource
path='http://localhost:7080/drools-
guvnor/org.drools.guvnor.Guvnor/package/com.foo.bar/LATEST'] for
listener=org.drools.agent.impl.KnowledgeAgentImpl@b71c17
07:58:16,738 KnowledgeAgent received ChangeSet changed notification
07:58:16,738 KnowledgeAgent received ChangeSet changed notification
07:58:16,738 KnowledgAgent applying ChangeSet
07:58:16,738 ResourceChangeNotification thread is waiting for queue update
07:58:16,738 KnowledgAgent applying ChangeSet
07:58:16,738 KnowledgeAgent unsubscribing from resource=[UrlResource
path='http://localhost:7080/drools-
guvnor/org.drools.guvnor.Guvnor/package/com.foo.bar/LATEST']
07:58:16,738 ResourceChangeNotification unsubscribing
listener=org.drools.agent.impl.KnowledgeAgentImpl@1053d6d to
resource=[UrlResource path='http://localhost:7080/drools-
guvnor/org.drools.guvnor.Guvnor/package/com.foo.bar/LATEST']
07:58:16,738 KnowledgeAgent rebuilding KnowledgeBase using ChangeSet
07:58:16,738 KnowledgeAgent unsubscribing from resource=[UrlResource
path='http://localhost:7080/drools-
guvnor/org.drools.guvnor.Guvnor/package/com.foo.bar/LATEST']
07:58:16,738 ResourceChangeNotification unsubscribing
listener=org.drools.agent.impl.KnowledgeAgentImpl@b71c17 to
resource=[UrlResource path='http://localhost:7080/drools-
guvnor/org.drools.guvnor.Guvnor/package/com.foo.bar/LATEST']
07:58:16,738
KnowledgeAgent rebuilding KnowledgeBase using ChangeSet
07:58:16,738 KnowledgeAgent new KnowledgeBase now built and in use
07:58:16,738 KnowledgeAgent new KnowledgeBase now built and in use
07:59:02,202 ResourceChangeScanner attempt to scan 0 resources
07:59:02,202 ResourceChangeScanner thread is waiting for 60
# Guvnor back up here
07:59:16,731 ResourceChangeScanner attempt to scan 0 resources
07:59:16,731 ResourceChangeScanner thread is waiting for 60
--
Nur noch bis 31.01.2010: DSL-Komplettpaket für 16,99 Euro/mtl.!*
http://portal.gmx.net/de/go/dsl02
13 years, 7 months
StatefulKnowledgeSession Vs StatefulSession
by DeepakA
I used a KnowledgeBuilder ro read the resources (DSL & DSLR files)
Then created a KnowledgeBase and created a StatefulKnowledgeSession out of
the KnowledgeBase.
The StatefulKnowledgeSession was used to start the process and fire all
rules.
Then I realized I was not able to access the RuleBase from
StatefulKnowledgeSession.
So, now I create a RuleBase, then a PackageBuilder, add the resources to the
packageBuilder, then add the
package to the RuleBase and create a StatefulSession out of the RuleBase.
This statefulsession is used to start the process and fire all rules.
Can someone explain to me whats the difference in the above 2 methods of
firing the rules.
Whats the difference between StatefulKnowledgeSession & StatefulSession.
--
View this message in context: http://old.nabble.com/StatefulKnowledgeSession-Vs-StatefulSession-tp26511...
Sent from the drools - user mailing list archive at Nabble.com.
13 years, 8 months
[Urgent] Error in ontext assist in DSLR Editor
by hamza bakkali
Hi All,
I have been using drools 4 for couple of months now and I am starting to get
the hang of it. We recently decided to move to Dools 5 with Eclipse 3.4.2
(Ganymede).
We unfortunately hit a major 'show stopper' (for us). In the DSLR editor:
Context Assist + space + enter removes/replaces the whole line, not only the
place holder.
In other words:
DSL:
[*][]Log : {msg}=System.out.println("{msg}");
[*][]id1="some id label"
DSLR:
rule "MyRule"
when
then
end
If I Press L , control space --> the line Log:{msg} appears in the context
menu. Hit enter I get
Log :{msg}
Now, If want to replace msg by id1. I position the cursor in the {msg}, hit
ctrl space, id1 shows in the list. I hit enter the whole line disappear, and
I am left with
id1
instead of
Log : id1
Is this a setting somewhere in eclipse itself?? I doubt it.
The same thing use to work as expected in Drools 4.
thanks.
13 years, 8 months
Drools planner & Scala
by Adam Warski
Hello,
I'm using Planner in a Scala program and it almost works without problems; the only one is in implementing the Solution interface, as it uses raw (erased) version of Score, which is normally generic (Score<S extends Score>). Scala generally doesn't like raw types and in most cases it's impossible to extend/implement interfaces which use them. A work-around is to introduce an "adapter" in Java, which you can later extend in Scala:
public abstract class ScalaSolution implements Solution {
public Score getScore() { return getScoreScala(); }
public abstract Score<?> getScoreScala();
public void setScore(Score score) { setScoreScala(score); }
public abstract void setScoreScala(Score<?> score);
}
and then in Scala:
class Schedule(...) extends ScalaSolution {
var score: Score[_] = _
def setScoreScala(score: Score[_]) = { this.score = score }
def getScoreScala = score
...
}
So the fix is to replace the raw Score type with Score<?>. Maybe it would be possible to apply that in the code? I tried it locally and it compiles without problems.
And a side question: do you have any plans on implementing multithreading in planner? So that several moves could be explored concurrently? I saw there's an open Jira issue for some time, but it didn't have any timeframe information.
--
Adam Warski
http://www.warski.org
http://www.softwaremill.eu
13 years, 8 months
How to specify relative URL in chagenset.xml file
by Pardeep Ruhil
Hi,
I am getting File Not Found Exception when I try to give relative path of the file.
<resource source='file:../HelloWorld.drl' type='DRL' />
But when I give the complete path, It picks the changeset.xml file.
<resource source='file:C:/Tomcat/webapps/DroolsCheck/HelloWorld.drl' type='DRL' />
Please tell me the syntax for using the relative path for my workflow or rule files.
Thanks & Regards
Pradeep Ruhil
________________________________
This Email may contain confidential or privileged information for the intended recipient (s) If you are not the intended recipient, please do not use or disseminate the information, notify the sender and delete it from your system.
______________________________________________________________________
13 years, 8 months