Date validation in Guvnor
by mick00
Hi,
I want to validate the date format in my rule. I just want to check whether
my date is in the given format(yyyy-mm-dd) in my rule in Guvnor. Is it
possible to do such validation in Guvnor? I tried the same but got an
exception stating that the date is not in the given format(dd-MMM-yyyy). Can
someone suggest a solution as to how to validate the date in Guvnor?
Thanks,
mick
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Date-validation-in-Gu...
Sent from the Drools - User mailing list archive at Nabble.com.
13 years, 2 months
Fusion and open-ended intervals?
by Barry Kaplan
A fusion design question:
I have events that represent intervals. Initially the intervals are
open-ended (kind a like the current state of an entity). Other events are
matched "during" the interval and correlated. At some point the interval
will be closed (eg, a specific downtime interval is closed because the
device is no online again).
All the events in this system are immutable -- so if some property of an
event changes, it is cloned and modified in working-memory. For the case of
the interval events, initially the interval is inserted open-ended, and at
some point later closed and then modified.
This does not work with fusion however, since an event's duration is
maintained by the fact-handle not the event itself. Hence a modify with a
now closed interval (ie, a finite @duration) has no effect. I'm guessing the
temporal values are maintained the handle to ensure stable values for the
behaviors that trigger based on temporal values, which is reasonable.
So I'm looking for alternative designs. Some are:
1) Modeled the intervals as begin/end events, but that gets messy real
fast (have to correlate
the begin/end events somehow, can't use evaluators like 'includes' or
'during', etc).
2) Retract the interval event when it is closed (this way closed intervals
no longer correlate
with other incoming events). But then we really have a manually
maintained state machine
using only facts, and there can be no reasoning over a series these
interval events.
(eg, 3 downtimes longer than 2 minutes in the last hour).
Opinions?
-barry
--
View this message in context: http://n3.nabble.com/Fusion-and-open-ended-intervals-tp719076p719076.html
Sent from the Drools - User mailing list archive at Nabble.com.
13 years, 2 months
Persistence of events
by Maciej Prochniak
Hello,
Is it possible to persist events (from drools fusion) with default jpa
mechanism? When I try to do this 'just like that' I get exception
like
org.drools.common.DefaultFactHandle incompatible with
org.drools.common.EventFactHandle
It seems that session marshaller is not really aware of certain objects
being events, not facts.
The code I try is more or less like:
UserTransaction ut = ...
StatefulKnowledgeSession session = JPAKnowledgeService
.newStatefulKnowledgeSession(kbase, null, env);
ut.begin()
session.insert(e1);
ut.commit();
StatefulKnowledgeSession sessionPersisted =
JPAKnowledgeService.loadStatefulKnowledgeSession( session.getId(),
kbase, null, env );
ut.begin()
sessionPersisted.insert(e2); (*) <- fails
ut.commit();
When I use session instead of sessionPersisted - it works fine, when
e2 is a fact, not an event - it also works
I know that it may be awkward to persist events which have time
limitations, but I want to use time limits in rules which are like few
days - so I want to have some persistence in case of server shutdown.
I would be grateful for any comment,
br,
maciek prochniak
13 years, 2 months
Guvnor test scenarios for rules that use globals
by Lisa Horton
In Guvnor 5.1 I have several rules that invoke services defined as globals. Rules that invoke methods on these globals run OK when deployed, but a test scenario that triggers such a rule gets an exception.
For example, with a global named "logger" a rule that has in its THEN clause:
logger.debug("customer was added to session");
Test Scenario that triggers this rule gets the error:
[Error: unable to access property (null parent): debug]
Thanks for your help.
13 years, 2 months
Log4j in the rules?
by granz@MIT.EDU
Hi,
Is it possible to use Log4j inside the rules (RHS)?? (drl file)
Thanks,
Fabrice
13 years, 2 months
Memory leak in 5.2/5.3
by Swindells, Thomas
I'm in the middle of trying to upgrade our application to Drools 5.2 from 5.1 however I keep facing out of memory issues (I've also tried on the current 5.3 beta).
I've simplified my code into the following test case which on my machine after about 600 or so iterations gives an Out of memory exception:
@Test
public void testCase() throws InterruptedException
{
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());
for(int i = 0; i < 1000; i++) {
System.out.println("Run " + i);
StatefulKnowledgeSession session = kbase.newStatefulKnowledgeSession();
for(int j = 0; j < 100; j++) {
session.insert(new byte[10240]);
}
session.dispose();
session = null;
System.gc();
}
}
Am I missing anything here - I'm calling session.dispose() which is all I believe is necessary when finishing the session, however using a profiler shows that all the StatefulKnowledgeSessionImpl and ReteooStatefulSessions are still present and therefore keeping hold of all the byte arrays and memory.
Using a profiler it shows that the GC roots of the StatefulKnowledgeSessionImpl are
kruntime of org.jbpm.process.instance.ProcessRuntimeImpl
kruntime of org.jbpm.process.instance.event.DefaultSignalManager
kruntime of org.jbpm.process.instance.timer.TimerManager
kruntime of org.drools.reteoo.ReteooStatefulSession
Similarly for the ReteooStatefulSession:
session of org.drools.impl.StatefulKnowledgeSessionImpl
session of org.drools.impl.StatefulKnowledgeSessionImpl
workingMemory of org.jbpm.process.instance.ProcessRuntimeImpl
workingMemory of org.jbpm.process.instance.ProcessRuntimeImpl
workingMemory of org.jbpm.process.instance.ProcessRuntimeImpl
Is this a known issue? Am I missing anything in my code above.
I guess the alternative is to reuse my sessions - what is the most efficient way to remove all the facts from the working memory and get it back into a pristine state?
Thanks,
Thomas
________________________________
**************************************************************************************
This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmaster(a)nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary.
NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00
**************************************************************************************
13 years, 2 months
Client code using RuleAgent API - Guvnor 5.1.1 - getting 401 error
by Achyutha, Venkata
Hi,
This error would be basic one but it's very frustrating to me to debug this, few days ago it use to work.
I deployed guvnor 5.1.1 war into web logic 10.3, created package with 4 rules, build and deploy, got package url.
Started using package url in properties file and passing file to RuleAgent api, suddenly it started giving HTTP response code: 401 for URL.
Any thoughts on this issue would be greatly appreciated.
Below is the content of properties file and Client code.
{url=http://10.117.39.51:7001/Guvnor5.1.1/org.drools.guvnor.Guvnor/package/com.tmobile.pos.rules/LATEST , name=myrules, username=weblogic, poll=30, newInstance=true, localCacheDir=C:\Installed\workspaces\drools\POC\bin, workspacepath=C://bea/user_projects/domains/posdomain, password=weblogic123, enableBasicAuthentication=true}
Error:
RuleAgent(myrules) INFO (Fri Nov 26 15:19:00 IST 2010): Configuring with newInstance=true, secondsToRefresh=30
RuleAgent(myrules) INFO (Fri Nov 26 15:19:00 IST 2010): Configuring package provider : URLScanner monitoring URLs: http://10.117.39.51:7001/Guvnor5.1.1/org.drools.guvnor.Guvnor/package/com... with local cache dir of C:\Installed\workspaces\drools\POC\bin
RuleAgent(myrules) EXCEPTION (Fri Nov 26 15:19:01 IST 2010): Server returned HTTP response code: 401 for URL: http://10.117.39.51:7001/Guvnor5.1.1/org.drools.guvnor.Guvnor/package/com.... Stack trace should follow.
java.io.IOException: Server returned HTTP response code: 401 for URL: http://10.117.39.51:7001/Guvnor5.1.1/org.drools.guvnor.Guvnor/package/com...
Client Code: (getting error at 3rd line)
File file = new File("C:\\guvnor.properties");
properties.load(new FileInputStream(file));
RuleAgent agent = RuleAgent.newRuleAgent(properties);
RuleBase ruleBase = agent.getRuleBase();
WorkingMemory workingMemory = ruleBase.newStatefulSession();
Thanks
Kumar
13 years, 2 months
Classloading error with AspectJ and Drools 5.2.0.Final
by Steven Williams
Hi,
I have just upgraded to Drools 5.2.0.Final and am getting a weird error when
running unit tests.
java.lang.NullPointerException
at org.aspectj.weaver.loadtime.ClassLoaderWeavingAdaptor.parseDefinitions(
ClassLoaderWeavingAdaptor.java:251)
at org.aspectj.weaver.loadtime.DefaultWeavingContext.getDefinitions(
DefaultWeavingContext.java:130)
at org.aspectj.weaver.loadtime.ClassLoaderWeavingAdaptor.initialize(
ClassLoaderWeavingAdaptor.java:161)
at
org.aspectj.weaver.loadtime.Aj$ExplicitlyInitializedClassLoaderWeavingAdaptor.initialize(
Aj.java:271)
at
org.aspectj.weaver.loadtime.Aj$ExplicitlyInitializedClassLoaderWeavingAdaptor.getWeavingAdaptor(
Aj.java:276)
at org.aspectj.weaver.loadtime.Aj$WeaverContainer.getWeaver(Aj.java:254)
at org.aspectj.weaver.loadtime.Aj.preProcess(Aj.java:90)
at org.aspectj.weaver.loadtime.ClassPreProcessorAgentAdapter.transform(
ClassPreProcessorAgentAdapter.java:54)
at sun.instrument.TransformerManager.transform(TransformerManager.java:169)
at sun.instrument.InstrumentationImpl.transform(InstrumentationImpl.java:365
)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632)
at java.lang.ClassLoader.defineClass(ClassLoader.java:616)
at org.drools.rule.JavaDialectRuntimeData$PackageClassLoader.fastFindClass(
JavaDialectRuntimeData.java:570)
at org.drools.util.CompositeClassLoader$CachingLoader.load(
CompositeClassLoader.java:258)
at org.drools.util.CompositeClassLoader$CachingLoader.load(
CompositeClassLoader.java:241)
at org.drools.util.CompositeClassLoader.loadClass(
CompositeClassLoader.java:88)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
at org.drools.rule.JavaDialectRuntimeData.wire(
JavaDialectRuntimeData.java:405)
at org.drools.rule.JavaDialectRuntimeData.wire(
JavaDialectRuntimeData.java:396)
at org.drools.rule.JavaDialectRuntimeData.onBeforeExecute(
JavaDialectRuntimeData.java:237)
at org.drools.rule.DialectRuntimeRegistry.onBeforeExecute(
DialectRuntimeRegistry.java:132)
at org.drools.compiler.PackageBuilder.reloadAll(PackageBuilder.java:796)
at org.drools.compiler.PackageBuilder.addPackage(PackageBuilder.java:751)
at org.drools.compiler.PackageBuilder.addPackageFromDrl(
PackageBuilder.java:360)
at org.drools.compiler.PackageBuilder.addKnowledgeResource(
PackageBuilder.java:538)
at org.drools.builder.impl.KnowledgeBuilderImpl.add(
KnowledgeBuilderImpl.java:28)
at au.com.promedicus.rules.KnowledgeBaseBuilder.addPackagesFromList(
KnowledgeBaseBuilder.java:108)
at au.com.promedicus.rules.KnowledgeBaseBuilder.build(
KnowledgeBaseBuilder.java:69)
at au.com.promedicus.rules.KnowledgeBaseBuilder.build(
KnowledgeBaseBuilder.java:54)
I have traced the problem to org.drools.rule.
JavaDialectRuntimeData$PackageClassLoader.getResources. This returns null
whereas AspectJ expects it to at least return an empty enumeration - hence
the NPE. Interestingly the problem does not occur when running our server,
however we can't upgrade unless our unit tests pass and we can't easily turn
off aspectj for these.
regards
Steve
13 years, 2 months
Druplicate rule name: 0
by bitter
I have 100 rules in xls decision table.
I modify any rule and save change. Then I try to build create new knwoledge
base using this file and I have exception:
java.lang.RuntimeException: [784,0]: Duplicate rule name: 0
[801,0]: Duplicate rule name: 0
[818,0]: Duplicate rule name: 0
[837,0]: Duplicate rule name: 0
[856,0]: Duplicate rule name: 0
[873,0]: Duplicate rule name: 0
[890,0]: Duplicate rule name: 0
[907,0]: Duplicate rule name: 0
[924,0]: Duplicate rule name: 0
[941,0]: Duplicate rule name: 0
[958,0]: Duplicate rule name: 0
[975,0]: Duplicate rule name: 0
[992,0]: Duplicate rule name: 0
[1009,0]: Duplicate rule name: 0
I tried to compile this file using SpreadSheetCompiler. This is a scrap of
drl file wth rules:
*
# rule values at A52, header at A5
rule "0"
salience 60
ruleflow-group "0"
when
*
--
View this message in context: http://drools.46999.n3.nabble.com/Druplicate-rule-name-0-tp3246425p324642...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 2 months
How to deploy Fusion ?
by eskomk
Hi all,
I'm new to Drools.
We need to have Fusion features in our systems, especially temporal
relations on events.
The problem is we don't know how to take Fusion in use.
Our rules do not fire, why ?
What are the steps to get Fusion up and running ?
We are using Drools as a web service, and it is fed with xml-formed facts
through REST interface.
Drools itself works ok.
We use Guvnor as rule editor, and have its snapshot included as CHANGE_SET
resource in knowledge-services.xml, so that's not a problem.
The rules we are now interested in sits in separate .drl files which are
read as DRL resources in knowledge-services.xml
(file contents below, with BBBafterAAA.drl as a resource).
As I have understood, we must change to stateful session from stateless, to
use Fusion.
This is so that we can define the event processing mode as STREAM in
kbase-definition,
and clock-type as REALTIME in session-definition.
We are primarily using Drools version 5.1.1 on several physical and virtual
servers
(we are just learning Drools for now, primaliry gathering data to be used in
Drools).
Now I am testing Drools version 5.3.0-SNAPSHOT (drools-camel-server),
where the config file snippet below are taken.
<path> below replaces the actual package names.
We have declared some incoming facts to be events (never mind the Bean
ending):
declares_drl.drl
{file}
package org.test;
import <path>.AAABean;
import <path>.BBBBean;
declare AAABean
@role(event)
end
declare BBBBean
@role(event)
end
{/file}
File BBBafterAAA.drl contents, withot THEN part:
{file}
package org.test;
import <path>.AAABean;
import <path>.BBBBean;
/*
declare AAABean
@role(event)
end
declare BBBBean
@role(event)
end
*/
rule "BBBAfterAAA"
dialect "mvel"
no-loop true
salience 100
when
$Aaa : AAABean();
$Bbb : BBBBean(this after[10s, 10m] $Aaa);
then
// Consequences go here
{/file}
File knowledge-services.xml contents:
{file}
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:drools="http://drools.org/schema/drools-spring"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://drools.org/schema/drools-spring
http://drools.org/schema/drools-spring-1.3.0.xsd">
<drools:grid-node id="node1"/>
<drools:resource-change-scanner id="scanner" interval="2" />
<bean name="CCCInitBean" class="<path>.InitBean">
<property name="initOk" value="false"/>
</bean>
<drools:kbase id="kbase1" node="node1">
<drools:resources>
<drools:resource type="DRL" source="classpath:test.drl"/>
<drools:resource type="DRL"
source="classpath:declares_drl.drl"/>
<drools:resource type="DRL"
source="classpath:BBBafterAAA.drl"/>
<drools:resource type="CHANGE_SET"
source="classpath:ChangeSet.xml"/>
</drools:resources>
<drools:configuration>
<drools:event-processing-mode mode="STREAM"/>
</drools:configuration>
</drools:kbase>
<drools:kagent id="kagent1" kbase="kbase1" new-instance="false">
<drools:resources>
<drools:resource type="CHANGE_SET" source="classpath:ChangeSet.xml"/>
</drools:resources>
</drools:kagent>
<drools:ksession id="ksession1" type="stateful" kbase="kbase1"
node="node1">
<drools:configuration>
<drools:clock-type type="REALTIME"/>
</drools:configuration>
<drools:batch>
<drools:insert-object ref="mirellaInitBean"/>
<drools:fire-all-rules />
</drools:batch>
</drools:ksession>
</beans>
{/file}
Cheers,
Esko
http://www.ebsolut.fi
--
View this message in context: http://drools.46999.n3.nabble.com/How-to-deploy-Fusion-tp3287119p3287119....
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 2 months