What should I insert into the working memory?
by Chris Selwyn
I am working on a project that is using Drools to perform validation of
hierarchical XML messages.
So I have passed the XSDs through JAXB and have a set of interrelated
Java objects.
One of these objects (naturally) represents the root of the messages and
the others represent the intermediate and leaf nodes of the message.
My question is: Should I traverse the tree and insert each object into
the working memory or should I just insert the root object into the
working memory?
If I insert each object into the memory then I have a lot of flexibility
about how I write my rules... I can start by focussing on the particular
part of the message that I want to detect an error in.
However, I then have to perform a whole bunch of "joining" clauses to
correctly "connect up" to the other objects in the working memory.
(This is how I am doing it at the moment... I have a mechanism that uses
the Java Introspector. It identifies by package name which parts of the
data model get inserted into the WM)
On the other hand, I could just insert the root object into the WM. This
means that I would have to write really complicated where clauses on the
root object but very much simplifies the WM loading process.
All of the examples that I have seen have a very simple flat
(non-hierarchical) structure that don't really give a hint as to what a
"best practice" might be.
Any suggestions/insights welcome :-)
Chris Selwyn
15 years, 6 months
Maven builds for drools-flow
by Brian Wallis
I'm trying to get a simple standalone drools-flow build working using maven and cannot seem to resolve the dependencies.
What are the dependencies for drools-flow? I've found mention of drools-flow-core and drools-flow-compiler but they are only available for 5.2.0 snapshot and I was wanting to use 5.1.1.
I'm having no end of problems with the 5.2.0-SNAPSHOT dependencies. I've attached the pom and here is the output I get:
t% mvn clean install
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building Coding Workflow
[INFO] task-segment: [clean, install]
[INFO] ------------------------------------------------------------------------
[INFO] [clean:clean {execution: default-clean}]
[INFO] Deleting directory /Users/bwallis/src/Drools/install/Coding/target
[INFO] [resources:resources {execution: default-resources}]
[WARNING] Using platform encoding (MacRoman actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 2 resources
[INFO] Copying 3 resources
[INFO] snapshot org.drools:drools-flow-core:5.2.0.SNAPSHOT: checking for updates from jboss-public-repository-group
Downloading: https://repository.jboss.org/nexus/content/groups/public/org/drools/drool...
3K downloaded (drools-flow-core-5.2.0.20101123.060233-137.pom)
[INFO] snapshot org.drools:drools:5.2.0.SNAPSHOT: checking for updates from jboss-public-repository-group
Downloading: https://repository.jboss.org/nexus/content/groups/public/org/drools/drool...
[INFO] Unable to find resource 'org.drools:drools:pom:5.2.0.SNAPSHOT' in repository jboss-public-repository-group (https://repository.jboss.org/nexus/content/groups/public)
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Error building POM (may not be this project's POM).
Project ID: null:drools-flow-core:jar:null
Reason: Cannot find parent: org.drools:drools for project: null:drools-flow-core:jar:null for project null:drools-flow-core:jar:null
[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 12 seconds
[INFO] Finished at: Sun Nov 28 14:01:25 EST 2010
[INFO] Final Memory: 18M/81M
[INFO] ------------------------------------------------------------------------
Brian Wallis
InfoMedix | Architect
p: 3 8615 4553 | f: 3 8615 4501
e: brian.wallis(a)infomedix.com.au
Level 5, 451 Little Bourke Street, Melbourne VIC 3000
15 years, 6 months
Drools-server and fact-IDs - emptying/resetting stateful sessions
by flo
Hello,
I'm currently working to setup a experimental drools decision service with
the drools-server component via REST. In the server, I run a stateful
session with rules from a guvnor repo. The stateful session absolutely needs
to stay stateful because I use some of the CEP features in my rules.
What I try to achieve at the moment is to "clean up" this session if my
client (there is just one single client)(re-)connects. That basically means
either to clear out the working memory by doing some retracts, or to reset
the whole server.
So, my first approach was a get-objects command to get handles to all
objects in the working memory (to retract them one after another), but soon
I discovered that the get-objects result doesn't provide fact-ids for its
results. As it seems, the same also applies to queries. But without fact-id,
no retracts can be made.
My second approach to reset the whole session or server also failed, because
there is no dedicated command for this and I'm not enough into java app
server stuff to implement something like that on the fly. But this solution
would also have the advantage that the rules would get reloaded after the
reset, which would really simplify things (as the resource change scanner
obviously doesn't work with guvnor and drools-server - at least I didn't get
it to work, and as it seems the problem is also know on this list).
So my question is - does someone know either how to reset the whole
drools-server via REST or alternatively a possibility how to gather all
facts in the WM with their corresponding fact ids?
Thanks for your help, really appreciate it!
Best regards,
flo
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Drools-server-and-fac...
Sent from the Drools - User mailing list archive at Nabble.com.
15 years, 6 months
Resuming rule flow using nodeId
by drdaveg
I've been working on a proof-of-concept where microseconds count and I need
more performance than JPAKnowledgeService's hibernate/jpa/jta stack can
provide. I can use process event listener's to get the processId, nodeId,
sessionId to persist the state of a rule flow but can't find an API that
would let me resume a rule flow, BPMN, or BPMN2 module at the node
corresponding to the nodeId.
Any thoughts on the code needed to start the process at the node having a
particular id within a rule flow? Thanks!
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Resuming-rule-flow-us...
Sent from the Drools - User mailing list archive at Nabble.com.
15 years, 6 months
Problem in getting session from JPAKnowledgeService.newStatefulKnowledgeSession();
by Bennet Joseph
Hi All,
follwoing is the code i used to get the session using
JPAKnowledgeService.newStatefulKnowledgeSession.
table for the mentioned classes are getting created, after that
JPAKnowledgeService.newStatefulKnowledgeSession() method throws following
exception....
EntityManagerFactory emf =
Persistence.createEntityManagerFactory( "org.drools.persistence.jpa" );
Environment env = KnowledgeBaseFactory.newEnvironment();
env.set( EnvironmentName.ENTITY_MANAGER_FACTORY, emf );
env.set( EnvironmentName.TRANSACTION_MANAGER,
TransactionManagerServices.getTransactionManager() );
StatefulKnowledgeSession ksession =
JPAKnowledgeService.newStatefulKnowledgeSession( kbase, null, env );
-------------------------
persistence.xml
i copied only persistent unit part...
<persistence-unit name="org.drools.persistence.jpa">
<class>org.drools.persistence.session.SessionInfo</class>
<class>org.drools.persistence.processinstance.ProcessInstanceInfo</class>
<class>org.drools.persistence.processinstance.ProcessInstanceEventInfo</class>
<class>org.drools.persistence.processinstance.WorkItemInfo</class>
<class>org.drools.persistence.processinstance.variabletypes.VariableInstanceInfo</class>
<class>org.drools.persistence.processinstance.variabletypes.JPAPersistedVariable</class>
<properties>
<property name="hibernate.dialect"
value="org.hibernate.dialect.Oracle10gDialect" />
<property name="hibernate.max_fetch_depth" value="3" />
<property name="hibernate.hbm2ddl.auto" value="update" />
<property name="hibernate.show_sql" value="true" />
<property name="hibernate.transaction.manager_lookup_class"
value="org.hibernate.transaction.BTMTransactionManagerLookup" />
<property name="hibernate.connection.url"
value="jdbc:oracle:thin:@192.168.4.93:1521:POST" />
<property name="hibernate.connection.driver_class"
value="oracle.jdbc.driver.OracleDriver" />
<property name="hibernate.connection.password" value="voms_test"
/>
<property name="hibernate.connection.username" value="voms_test"
/>
<property name="java.naming.factory.initial"
value="bitronix.tm.jndi.BitronixInitialContextFactory"/>
<!--
<property name="hibernate.format_sql" value="true"/>
-->
</properties>
</persistence-unit>
but it throws exception
java.lang.IllegalStateException: java.lang.reflect.InvocationTargetException
at
org.drools.persistence.jpa.impl.KnowledgeStoreServiceImpl.buildCommanService(KnowledgeStoreServiceImpl.java:137)
at
org.drools.persistence.jpa.impl.KnowledgeStoreServiceImpl.newStatefulKnowledgeSession(KnowledgeStoreServiceImpl.java:61)
* at
org.drools.persistence.jpa.JPAKnowledgeService.newStatefulKnowledgeSession(JPAKnowledgeService.java:109)
at com.sample.FirstTest.main(FirstTest.java:87)*
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown
Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at
org.drools.persistence.jpa.impl.KnowledgeStoreServiceImpl.buildCommanService(KnowledgeStoreServiceImpl.java:123)
... 3 more
Caused by: java.lang.RuntimeException: Could not commit session or rollback
at
org.drools.persistence.session.SingleSessionCommandService.<init>(SingleSessionCommandService.java:132)
... 8 more
Caused by: java.lang.RuntimeException: Unable to rollback transaction
at
org.drools.persistence.session.JtaTransactionManager.rollback(JtaTransactionManager.java:181)
at
org.drools.persistence.session.SingleSessionCommandService.<init>(SingleSessionCommandService.java:130)
... 8 more
Caused by: java.lang.NullPointerException
at
org.drools.persistence.session.JtaTransactionManager.rollback(JtaTransactionManager.java:178)
... 9 more
15 years, 6 months
forall not delivering as expected
by Wolfgang Laun
Given classes
class Triangle { int a, b, c;... }
class Quadrangle { int a, b, c, d;... }
with appropriate getters (but no hashCode or equals) and these facts
Triangle( 3, 3, 3 )
Triangle( 3, 3, 3 ) // a duplicate, intentional
Quadrangle ( 3, 4, 5, 6 );
the rule
rule "all equilaterals have a 'fitting' quadrangle"
when
forall( Triangle( $a: a, b == $a, c == $a )
Quadrangle( a == $a || b == $a || c == $a || d == $a ) )
then // ...
end
works as expected - it fires.
But the rule
rule "all equilaterals have a duplicate"
when
forall( $t: Triangle( $a: a, b == $a, c == $a )
Triangle( this != $t, a == $a, b == $a , c == $a ) )
then // ...
end
does not fire, not even when I omit this != $t. Why?
Do I have a white spot in my grey cells? Please tint my taint...
-W
15 years, 7 months
How to store Session or session info.
by Bennet Joseph
Hi All,
i am trying to execute the flow, and it is persisting history log in
ProcessInstanceLog and NodeInstanceLog.
if the server crashes, from where i have to retrive the session details.
Thanks,
Jose.
15 years, 7 months
Start TaskServer in Execution Server
by raic
Hi,
There is a way for starting the MinaTaskServer at ExecutionServer startup? I
want to configure TaskServer out of the application and to have it always
"up".
I mean to replace this code from the application to some configuration in
execution server:
EntityManagerFactory emf =
Persistence.createEntityManagerFactory("org.drools.task");
TaskService taskService = new TaskService(emf,
SystemEventListenerFactory.getSystemEventListener());
TaskServiceSession taskSession = taskService.createSession();
taskSession.addUser(new User("Administrator"));
taskSession.addUser(new User("foo"));
taskSession.addUser(new User("foo1"));
MinaTaskServer server = new MinaTaskServer(taskService);
Thread thread = new Thread(server);
thread.start();
Any idea will be appreciated
Thanks!
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Start-TaskServer-in-E...
Sent from the Drools - User mailing list archive at Nabble.com.
15 years, 7 months