Best practice for using calendar-based rules?
by dunnlow
Hi,
I am using drools 5.4 via the web-based server (running in tomcat). My
rulebase is stored (and created/maintained) in guvnor.
I have a template rule (in guvnor) that I use to define alert conditions.
The template has a few columns that allow users to specify several
properties of an event on which they would like to be alerted. For example,
they can change integer thresholds, set regular expression strings to check
against, etc. This has been working well.
Now, I want to add a calendar-based aspect to the template rule. So, a user
can specify something like, "tell me if an event like this comes in AND it
is a weekend."
I have considered making a java function or pojo that interprets some string
in a template column, which I would then use in the template rule to return
true/false. I also considered making a canned set of weekly and daily
Quartz calendars so that they could provide a list of calendar names to use.
For example "weekendsOnly, offHoursOnly" etc.
My question: Have you done anything like this or do you have any thoughts
about a clean way to implement it? Is there something simple I am missing?
Thanks for any insight,
-J
--
View this message in context: http://drools.46999.n3.nabble.com/Best-practice-for-using-calendar-based-...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 4 months
stack shape inconsistent on rule evaluation
by Jörg Herbst
Hi,
I've configured a central rule engine which provides dynamic rule
evaluation and expose this service as a webservice. Most times everything
works fine but sometimes a get a "stack shape inconsistent" exception on a
default consequence invoker.
(Drools Version is 5.2.3.Final, Java version 5, mvel is 2.1.0.drools16)
Any hints?
Joerg
12 years, 4 months
Write Error when Serializing a stateful session to a file.
by chrisLi
Hi, all
I am trying to serialize a StatefulKnowledgeSession into a file as a
snapshot. But I got the following error:
java.io.IOException: Write error
at java.io.FileOutputStream.writeBytes(Native Method)
at java.io.FileOutputStream.write(FileOutputStream.java:282)
at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:65)
at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:123)
at
java.io.ObjectOutputStream$BlockDataOutputStream.flush(ObjectOutputStream.java:1793)
at java.io.ObjectOutputStream.flush(ObjectOutputStream.java:699)
at java.io.ObjectOutputStream.close(ObjectOutputStream.java:720)
at com.sample.test.EventDataConsumer.run(EventDataConsumer.java:44)
at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
However, when I serialized it to a ByteArrayOutputStream, it works well.
I wrapped the stateful session in a class as a field. And I wrote
writeObject and readObject methods in this class to provide custom
serializing behaviour. The code is as follows:
private void writeObject(ObjectOutputStream out) throws IOException {
System.out.println("writing");
out.defaultWriteObject();
DroolsObjectOutputStream droolsOut = new DroolsObjectOutputStream(
(OutputStream) out);
droolsOut.writeObject(knowledgeBase);
Marshaller marshaller = createSerializableMarshaller(knowledgeBase);
marshaller.marshall(droolsOut, session);
System.out.println("written");
}
private void readObject(ObjectInputStream in) throws IOException,
ClassNotFoundException {
System.out.println("read");
in.defaultReadObject();
DroolsObjectInputStream droolsIn = new DroolsObjectInputStream(
(InputStream) in);
this.knowledgeBase = (KnowledgeBase) droolsIn.readObject();
Marshaller marshaller = createSerializableMarshaller(knowledgeBase);
session = marshaller.unmarshall(droolsIn);
}
private Marshaller createSerializableMarshaller(KnowledgeBase
knowledgeBase) {
ObjectMarshallingStrategyAcceptor acceptor = MarshallerFactory
.newClassFilterAcceptor(new String[] { "*.*" });
ObjectMarshallingStrategy strategy = MarshallerFactory
.newSerializeMarshallingStrategy(acceptor);
Marshaller marshaller = MarshallerFactory.newMarshaller(knowledgeBase,
new ObjectMarshallingStrategy[] { strategy });
return marshaller;
}
Out of this class, I utilized the ordinary ObjectoutputStream to serialize
an instance of this class to a file.
Unfortunately, I got the Exception.
Any idea or response will be appreciated, Thank you very much.
--
View this message in context: http://drools.46999.n3.nabble.com/Write-Error-when-Serializing-a-stateful...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 4 months
comparing strings using ignore case
by abhinay_agarwal
hey,
is there a method by which i can compare two string ignoring there case ??
for me writing the code as
foo : ObjectTypeA()
bar : ObjectTypeB( name.equalsIgnoreCase( foo.name ) )
is a long process because i m comparing the values of string which are
present inside a map..and there are loads of comparision..
$h : HashMap(this["Account_Ownership_Type"]=="Single")
Does drools have an easier way for ignore case comparision ??
Thanks,
Abhinay
--
View this message in context: http://drools.46999.n3.nabble.com/comparing-strings-using-ignore-case-tp4...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 4 months
Migrating from 4.0.7 to 5.4.0.Final
by JP Chemali
Hi all,
I'm currently in the process of migrating an application using drools 4.0.7
to 5.4.0.Final and I've stumbled into a few issues with the new version that
I find disturbing:
- Our unit tests failed because the JVM ran out of perm gen space, which
looks odd as in 4.0.7 we've had quite a margin to start with.
- Doing several Yourkit analysis, I finally find classloading leaks:
* *org.drools.rule.builder.dialect.asm.ClassGenerator.EMPTY_METHOD_BODY*
is a static instance which will hold to the last instance of
InternalClassLoader created
* *org.drools.rule.constraint.MvelConstraint* uses an ExecutorHolder that
spawns daemon threads and keeps them in a pool. Problem is these threads
create class loaders, and can only be garbage collected when the thread
dies, meaning never in my case...
- I've quick fixed both issues, the second one by simply disabling the
thread pool.
- Once this is done, the perm gen behaves correctly, but the execution times
are 2-3 times slower on very large set of rules (~1000). Looking at Yourkit
analysis again, I see that the number of classes generated and the perm gen
consumption is about 3 times higher in 5.4.0.Final. I honestly don't know
how to address this.
I've tried to find some other posts concerning these issues, to no avail. I
don't see any work around this, short of code changes, and for reducing the
number of generated classes I simply have no idea.
Please correct me if I am wrong, any help would be greatly appreciated
--
View this message in context: http://drools.46999.n3.nabble.com/Migrating-from-4-0-7-to-5-4-0-Final-tp4...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 4 months