using after in calendar rule
by Alexander Wolf
Following rule does not work for me (see exception) - I got the impression that having a calendar for a rule that uses "after" leads to this. Any ideas? (Version 5.5.0 Final)
The point of time I get the exception is NOT within the defined calendar time (the rule should actually be ignored at that time...)
rule "myrule"
calendars "myCalendar"
when
//an event
$event: Event() from entry-point "EventStream"
//no more events after
not (Event(this after[0 , 30m] $event)from entry-point "EventStream" )
then
//actions
end
Exception in thread "main" org.drools.RuntimeDroolsException: Unexpected exception executing action org.drools.reteoo.PropagationQueuingNode$PropagateAction@56a75737
at org.drools.common.AbstractWorkingMemory.executeQueuedActions(AbstractWorkingMemory.java:995)
at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:362)
at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:311)
at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:127)
at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:55)
at Application.runSimulation(Test.java:173)
at Application.main(Test.java:68)
Caused by: java.lang.NullPointerException
at org.drools.time.impl.PseudoClockScheduler.removeJob(PseudoClockScheduler.java:147)
at org.drools.common.Scheduler.removeAgendaItem(Scheduler.java:75)
at org.drools.common.DefaultAgenda.removeScheduleItem(DefaultAgenda.java:475)
at org.drools.common.DefaultAgenda.removeActivation(DefaultAgenda.java:352)
at org.drools.common.DefaultAgenda.cancelActivation(DefaultAgenda.java:688)
at org.drools.reteoo.RuleTerminalNode.retractLeftTuple(RuleTerminalNode.java:322)
at org.drools.reteoo.SingleLeftTupleSinkAdapter.doPropagateRetractLeftTuple(SingleLeftTupleSinkAdapter.java:224)
at org.drools.reteoo.SingleLeftTupleSinkAdapter.propagateRetractLeftTuple(SingleLeftTupleSinkAdapter.java:98)
at org.drools.reteoo.NotNode.retractLeftTuple(NotNode.java:216)
at org.drools.reteoo.CompositeLeftTupleSinkAdapter.doPropagateRetractLeftTuple(CompositeLeftTupleSinkAdapter.java:250)
at org.drools.reteoo.CompositeLeftTupleSinkAdapter.propagateRetractLeftTuple(CompositeLeftTupleSinkAdapter.java:131)
at org.drools.reteoo.NotNode.propagateRetractLeftTuple(NotNode.java:444)
at org.drools.reteoo.NotNode.assertObject(NotNode.java:140)
at org.drools.reteoo.SingleObjectSinkAdapter.propagateAssertObject(SingleObjectSinkAdapter.java:59)
at org.drools.reteoo.PropagationQueuingNode$AssertAction.execute(PropagationQueuingNode.java:426)
at org.drools.reteoo.PropagationQueuingNode.propagateActions(PropagationQueuingNode.java:280)
at org.drools.reteoo.PropagationQueuingNode$PropagateAction.execute(PropagationQueuingNode.java:588)
at org.drools.common.AbstractWorkingMemory.executeQueuedActions(AbstractWorkingMemory.java:993)
... 6 more
- Alex
11 years, 3 months
Issue with Trait feature
by braveheart85
Hello,
I'm just trying trait feature with simple example.
I want trait a PersonData object with a SubjectData trait. My DLR is:
package general
import com.sample.PersonData
declare trait SubjectData
identifierCode : String
selected : boolean
end
rule "PersonToSubject"
when
$p : PersonData( )
then
SubjectData s = don( $p, SubjectData.class, true);
end
and my PersonData class is:
package com.sample;
import java.util.ArrayList;
import java.util.List;
public class PersonData {
protected String identifierCode;
protected List<String> addressList;
protected boolean isSelected;
public String getIdentifierCode() {
return identifierCode;
}
public void setIdentifierCode(String value) {
this.identifierCode = value;
}
public List<String> getAddressList() {
if (addressList == null) {
addressList = new ArrayList<String>();
}
return this.addressList;
}
public boolean isSelected() {
return isSelected;
}
public void setSelected(boolean isSelected) {
this.isSelected = isSelected;
}
}
when i run the engine i get an ugly exception:
Exception executing consequence for rule "PersonToSubject" in general:
org.drools.RuntimeDroolsException: Field/method 'addressList' not found for
class 'org.titan.registry.PersonDataWrapper'
at
org.drools.runtime.rule.impl.DefaultConsequenceExceptionHandler.handleException(DefaultConsequenceExceptionHandler.java:39)
at
org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1297)
at
org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:1221)
at
org.drools.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1456)
at
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:710)
at
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:674)
at
org.drools.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:230)
at com.sample.DroolsTest.main(DroolsTest.java:143)
Caused by: org.drools.RuntimeDroolsException: Field/method 'addressList' not
found for class 'org.titan.registry.PersonDataWrapper'
at
org.drools.base.ClassFieldAccessorFactory.getClassFieldWriter(ClassFieldAccessorFactory.java:199)
at
org.drools.base.ClassFieldAccessorCache$CacheEntry.getWriteAccessor(ClassFieldAccessorCache.java:187)
at
org.drools.base.ClassFieldAccessorCache.getWriteAcessor(ClassFieldAccessorCache.java:116)
at
org.drools.base.ClassFieldAccessorStore.wire(ClassFieldAccessorStore.java:439)
at
org.drools.base.ClassFieldAccessorStore.getAccessor(ClassFieldAccessorStore.java:219)
at
org.drools.factmodel.traits.TraitFactory.buildWrapperClassDefinition(TraitFactory.java:405)
at
org.drools.factmodel.traits.TraitFactory.getCoreWrapper(TraitFactory.java:367)
at
org.drools.base.DefaultKnowledgeHelper.asTraitable(DefaultKnowledgeHelper.java:560)
at
org.drools.base.DefaultKnowledgeHelper.applyTrait(DefaultKnowledgeHelper.java:542)
at
org.drools.base.DefaultKnowledgeHelper.don(DefaultKnowledgeHelper.java:521)
at
general.Rule_PersonToSubject_38ef6f901e5f401e805934fa0a2576c9.defaultConsequence(Rule_PersonToSubject_38ef6f901e5f401e805934fa0a2576c9.java:7)
at
general.Rule_PersonToSubject_38ef6f901e5f401e805934fa0a2576c9DefaultConsequenceInvokerGenerated.evaluate(Unknown
Source)
at
general.Rule_PersonToSubject_38ef6f901e5f401e805934fa0a2576c9DefaultConsequenceInvoker.evaluate(Unknown
Source)
at
org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1287)
... 6 more
Seem to be an issue with java.util.List that is contained within PersonData,
even if the list (addressList) is not selected from SubjectData trait.
Thanks in advance
Best regards
Andrea
--
View this message in context: http://drools.46999.n3.nabble.com/Issue-with-Trait-feature-tp4025937.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years, 3 months
KnowledgeAgent with persistence?
by dunnlow
I'm using Drools 5.5 (and guvnor)
Can anyone point me to example where a knowledge agent is used with
persistence. I am trying to understand how the knowledgeagent is used with
a persisted session. Fundamentally when my app starts, I am trying to do
one of two things:
If a persisted session does not exist, start a new one and update it
whenever my knowledgebase (in guvnor) changes
ELSE
If a persisted session already exists (i.e. at a system restart), load the
existing session and continue to monitor it for changes.
I have the persistence working and the monitoring of changes (with a
knowledgeagent) working independently, but not together.
My code:
Environment env = KnowledgeBaseFactory.newEnvironment();
env.set(EnvironmentName.ENTITY_MANAGER_FACTORY,myEMF);
env.set(EnvironmentName.TRANSACTION_MANAGER, myTxManager);
To create/retrieve my ksession I have tried both:
ksession =
JPAKnowledgeService.newStatefulKnowledgeSession(kAgent.getKnowledgeBase(),null,env)
This creates a persisted session, but it is never updated with changes
I also tried:
ksession =
kAgent.getKnowledgeBase().newStatefulKnowledgeSession(null,env);
This updates the ksession with changes, but never persists the session
I figure I can add a KnowledgeAgentEventListener to the agent and then
recreate the ksession by hand (in the knowledgeBaseUpdated method). But I
am hoping there is a cleaner/better way.
Thanks for any ideas.
-J
--
View this message in context: http://drools.46999.n3.nabble.com/KnowledgeAgent-with-persistence-tp40258...
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years, 3 months
Dynamic ValueRangeProvider
by Andrew Varner
Optaplanners,
I'm looking to add some dynamic goodness to ValueRangeProvider. The only way I see to specify a ValueRangeProvider is via annotation.
I'd like to be able to generate the id and Collection of candidate values dynamically. Is it possible to generate the ValueRangeProvider data outside of an annotation?
For example:
public class MyDataSource {
public Collection getValues(String id) {
…
return values;
}
}
Thanks,
Drew
11 years, 3 months
WG: Drools Fusion 6.0.0.CR3
by Weiss, Wolfgang
Hi all!
I tried out Drools 6.0.0.CR3 and I have some difficulties in detecting patterns with rules containing temporal parameters. I'm using following rule:
rule "detect turn shifts"
agenda-group "evaluation"
salience 100
when
$aae : AudioActivityEvent(value >= 50) from entry-point "LowLevelES"
not(AudioActivityEvent(value < 50, userID == $aae.userID, this after[0, 300ms] $aae) from entry-point "LowLevelES")
then
logger.info("turn shift START, user ID: " + $aae.getUserID() + ", " + $aae.toString());
// do something else ...
end
When inserting events following happens:
12:43:05,914 [main ] DEBUG ReteooRuleBase - Starting Engine in PHREAK mode
12:43:06,225 [main ] INFO SemanticLifter - incoming event: AudioActivityEvent [userID=1, value=100.0]
12:43:06,295 [main ] INFO SemanticLifter - incoming event: AudioActivityEvent [userID=1, value=0.0]
12:43:06,344 [main ] INFO SemanticLifter - incoming event: AudioActivityEvent [userID=1, value=100.0]
12:43:11,096 [main ] INFO SemanticLifter - incoming event: AudioActivityEvent [userID=1, value=0.0]
12:43:11,100 [main ] INFO SemanticLifter - turn shift START, user ID: 1, AudioActivityEvent [userID=1, value=100.0]
...
The "turn shift start" should be detected 300ms after the third incoming event (12:43:06,344) which is not the case here. This rule worked for me when using Drools 5.5.0 and 6.0.0.Beta2 but not with 6.0.0.CR3 - I did not try any other version.
This is my code to insert events:
streamEntryPoint = ksession.getEntryPoint("LowLevelES");
...
streamEntryPoint.insert(lowLevelEvent);
ksession.getAgenda().getAgendaGroup("evaluation").setFocus();
ksession.fireAllRules();
"AudioActivityEvent" is declared as an event with the @role attribute. I also tried to use the following option: "RuleEngineOption.RETEOO", but with no difference.
Best regards,
Wolfgang
11 years, 3 months
A Drools CEP Scenario - did I get it right?
by amarok
I got the following scenario:
- I need a Web Service that reasons over received sensor events (1000+ per
day and client) in realtime and send messages if certain patterns occur.
- The web service has many clients (100-1000) but their events / facts do
not interfere (each client has his own state and events that change his
state).
- Each client also has his own rules (10-100) (but they are parameterized
generic rules - I thought maybe I could use rule templates or DSL to let
clients individualize their rules).
- Some rules are time dependant (e.g. if event (type=x) does not occour at
least within half an hour after 8:00 a.m. (where 8 o'clock is a rule
parameter) -> send a message), others are accumulative (e.g. if number of
events within 5h is > 3).
I'd like to use drools CEP for this. I already read some documentation and
tutorials but my first examples do not really work as I expected. Now I fear
to have some general misconception about Drools/CEP. If someone could have a
look over my ideas, I'd be very glad!
How I would do it:
-> Every client would have his own KnowledgeBase with his (individualized)
rules. Rules would be stored in guvnor or on a mysql database as plain text.
-> Every client would have his own KnowledgeBase / StatefullKnowledgeSession
on the service, that knows about recent sensor events and some facts about
the client. Events automatically are disposed of once they are not relevant
anymore.
-> A static hashmap will hold references to the session for each client.
(clientID -> KnowledgeSession)
-> Sessions are created when a new client joins the system, but are normally
not disposed unless the client completely leaves the system.
-> When a new Event is received (HTTP PUT), the session corresponding to the
client would be retrieved from the HashMap and the new event would be
inserted via an event stream. Then (for every new event)
session.fireAllRules() would be called on the clients KnowledgeSession.
-> The Knowledge Base would run in STREAM mode to be able to reason over
time windows and automatically expire (=delete?!) events. This would keep
memory usage in within bounds(?)
-> pseudo clock allows me to write tests or simulate the system with records
of old events. (Is it possible to test timer, cron and sliding-window rules
with pseudo clock? Can I explicitly set the time of the pseudo clock?)
I appreciate your help!
--
View this message in context: http://drools.46999.n3.nabble.com/A-Drools-CEP-Scenario-did-I-get-it-righ...
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years, 3 months
MultiThreaded Drools implemetation
by ashwindrool
Hi,
I need to implement multithread drools execution.
Following i want to do
1. Load more than one drools rule set say drl1 and drl2.
2. Use core data model (facts) such that when independent thread executing
rules it doesnot modify facts simultaneously otherwise other drl wont get
executed.
3. Merging output of both drls into one output model.
Can any one provide me example to above conditions
Thnks....
--
View this message in context: http://drools.46999.n3.nabble.com/MultiThreaded-Drools-implemetation-tp40...
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years, 3 months