How to synchronize the Guvnor repository and the displaying of Guvnor UI?
by tim
Hi,
I have set up two instances of Guvnor in two separate Linux lab (lab1 and
lab2).
Each instance uses a separate MySQL database as its repository.
Two MySQL instances are deployed on lab1 and lab2 respectively, and are
configured as a replication mate, master-master mode.
When I create a new category from lab1's Guvnor UI, the change of the
repository can be synchronized to lab2's MySQL database. But the new
category can't be displayed in the lab2's Guvnor UI unless I restart the
tomcat on lab2.
Can you tell me how can I see the changes synchronously from the lab2's
Guvnor UI? Any suggestion will be appreciated.
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/How-to-synchronize-th...
Sent from the Drools - User mailing list archive at Nabble.com.
14 years, 2 months
Nested classes in the fact model in Guvnor
by Chris Selwyn
If I have nested classes in my Java model, I find that the Guvnor is
giving me the option to import classes using a "$" as the separator
between the containing class name and the nested classname.
However, validation of rules always fails saying that the class name
with the "$" in it cannot be resolved.
If I change these into "." then the problem goes away.
Is this a known problem or am I missing something?
I am using Drools 5.1.1
Chris Selwyn
14 years, 2 months
Simple DSL example
by morge
Hi everybody,
I try to run a simple DSL example.
My DRL is as follows:
package org.mydrools.examples
#must be in the following order.
import org.mydrools.examples.Person
import org.mydrools.examples.Cheese
#refer to test_expander.dsl
expander test_expander.dsl
rule "my rule"
when
#Person(name=="Dani", likes=="maroilles")
#Cheese(type=="maroilles")
There is a person with the name of Dani who likes maroilles
There is some maroilles cheese available
then
Add the message "We have a winner"
#System.out.println("We have a winner");
end
My DSL is as follow:
#some description
[when]There is a person with the name of {name} who likes
{cheese}=Person(name=="{name}", likes=="{cheese}")
[when]There is some {cheese} cheese available=Cheese(type=="{cheese}")
[then]Add the message {message}=System.out.println({message});
[when]person with eval=p : Person() eval(p.getName().equals("fire"))
And I load them as below:
kbuilder.add(ResourceFactory.newClassPathResource("test_expander.dsl"),ResourceType.DSL);
kbuilder.add(ResourceFactory.newClassPathResource("Sample.drl"),
ResourceType.DRL);
The following error messages appear:
[8,9]: [ERR 101] Line 8:9 no viable alternative at input 'test_expander' in
rule expander
[11,0]: [ERR 101] Line 11:0 no viable alternative at input 'rule' in rule
expander in rule dsl
[15,2]: [ERR 101] Line 15:2 no viable alternative at input 'There' in rule
expander in rule dsl in rule "my rule"
Any idea ?
Thanks in advance,
Maxime.
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Simple-DSL-example-tp...
Sent from the Drools - User mailing list archive at Nabble.com.
14 years, 2 months
Deadlock with multiple Entry Points
by Norman C
Drools can deadlock when facts are inserted/retracted/modified in multiple entry
points in the same session. Since each such action will acquire the lock
associated with the entry point, it's possible for the order of calls to cause
deadlock when the locks for two entry points are acquired by two different
threads, then the change in working memory activates and executes rules which
also insert/retract/modify and thus require acquiring the lock for the other
entry point.
As far as I can tell, there is no way to prevent this kind of deadlock other
than using only one entry point. Can anyone think of others?
In my case, I'm using Drools Fusion with two different entry points for events.
Whenever events expire, the engine automatically retracts them, so there are
lots of opportunities for the locks from each entry point to be acquired after
already holding the other entry point's lock. I used two different entry points
to separate different types of events for code clarity, so it's a simple
workaround in my application to consolidate all my events to use a single entry
point.
I can't think of a compelling reason for employing different entry points, so
maybe this isn't a big issue. But it would be good to know if there is another
way of preventing deadlock with multiple entry points.
Thanks,
Norman
14 years, 2 months
How do I persist at every node transition?
by kirakane
I setup JPA persistence using a MySQL DB and the BTM transaction manager as a
stand alone J2SE application. I'm trying to setup to be able to continue
from the last transition on a workflow if a process dies in the middle.
I have show sql turned on and I can see the ProcessInstance get saved at the
start but not at any of the node transitions. So if I kill the process in
the middle or simulate an outage and recover the session using
ksession = JPAKnowledgeService.loadStatefulKnowledgeSession(
sessionID, kbase, null, env );
the process restarts from the very beginning which is not the behavior I
desire.
For example for the RulesFlow
Start->A->B->C->End
and the server dies in B I would like the process to pickup from B.
How do I get this behavior?
Log:
--------------------------
create jpa backed stateful ksession
Hibernate: insert into SessionInfo (lastModificationDate, rulesByteArray,
startDate, OPTLOCK) values (?, ?, ?, ?)
Oct 18, 2010 10:56:14 AM bitronix.tm.twopc.Preparer prepare
WARNING: executing transaction with 0 enlisted resource
SESSIONID:80
Object Persisted
Hibernate: update SessionInfo set lastModificationDate=?, rulesByteArray=?,
startDate=?, OPTLOCK=? where id=? and OPTLOCK=?
Starting Process...
Hibernate: insert into ProcessInstanceInfo (externalVariables,
lastModificationDate, lastReadDate, processId, processInstanceByteArray,
startDate, state, OPTLOCK) values (?, ?, ?, ?, ?, ?, ?, ?)
Hibernate: update ProcessInstanceInfo set externalVariables=?,
lastModificationDate=?, lastReadDate=?, processId=?,
processInstanceByteArray=?, startDate=?, state=?, OPTLOCK=? where
InstanceId=? and OPTLOCK=?
Hibernate: insert into EventTypes (InstanceId, element) values (?, ?)
Hibernate: update SessionInfo set lastModificationDate=?, rulesByteArray=?,
startDate=?, OPTLOCK=? where id=? and OPTLOCK=?
Fire All Rules...
Created Status:VirusScanStatus [count=0, status=null, unquarantineCount=0]
Hibernate: select processins0_.InstanceId as col_0_0_ from
ProcessInstanceInfo processins0_ where ? in (select eventtypes1_.element
from EventTypes eventtypes1_ where
processins0_.InstanceId=eventtypes1_.InstanceId)
Hibernate: select processins0_.InstanceId as InstanceId1_0_,
processins0_.externalVariables as external2_1_0_,
processins0_.lastModificationDate as lastModi3_1_0_,
processins0_.lastReadDate as lastRead4_1_0_, processins0_.processId as
processId1_0_, processins0_.processInstanceByteArray as processI6_1_0_,
processins0_.startDate as startDate1_0_, processins0_.state as state1_0_,
processins0_.OPTLOCK as OPTLOCK1_0_ from ProcessInstanceInfo processins0_
where processins0_.InstanceId=?
In virus scanner:DocumentId [doc_id=THIS IS A DOCUMENT ID 1234]
did the scan:VirusScanStatus [count=1, status=success, unquarantineCount=0]
Hibernate: select processins0_.InstanceId as col_0_0_ from
ProcessInstanceInfo processins0_ where ? in (select eventtypes1_.element
from EventTypes eventtypes1_ where
processins0_.InstanceId=eventtypes1_.InstanceId)
remove from quarentine:DocumentId [doc_id=THIS IS A DOCUMENT ID 1234]
Hibernate: select processins0_.InstanceId as col_0_0_ from
ProcessInstanceInfo processins0_ where ? in (select eventtypes1_.element
from EventTypes eventtypes1_ where
processins0_.InstanceId=eventtypes1_.InstanceId)
VirusScanStatus [count=1, status=failed, unquarantineCount=1] sleeping:1000
Hibernate: select processins0_.InstanceId as col_0_0_ from
ProcessInstanceInfo processins0_ where ? in (select eventtypes1_.element
from EventTypes eventtypes1_ where
processins0_.InstanceId=eventtypes1_.InstanceId)
Hibernate: select processins0_.InstanceId as col_0_0_ from
ProcessInstanceInfo processins0_ where ? in (select eventtypes1_.element
from EventTypes eventtypes1_ where
processins0_.InstanceId=eventtypes1_.InstanceId)
entering state
remove from quarentine:DocumentId [doc_id=THIS IS A DOCUMENT ID 1234]
Hibernate: select processins0_.InstanceId as col_0_0_ from
ProcessInstanceInfo processins0_ where ? in (select eventtypes1_.element
from EventTypes eventtypes1_ where
processins0_.InstanceId=eventtypes1_.InstanceId)
VirusScanStatus [count=1, status=failed, unquarantineCount=2] sleeping:4000
Hibernate: select processins0_.InstanceId as col_0_0_ from
ProcessInstanceInfo processins0_ where ? in (select eventtypes1_.element
from EventTypes eventtypes1_ where
processins0_.InstanceId=eventtypes1_.InstanceId)
Hibernate: select processins0_.InstanceId as col_0_0_ from
ProcessInstanceInfo processins0_ where ? in (select eventtypes1_.element
from EventTypes eventtypes1_ where
processins0_.InstanceId=eventtypes1_.InstanceId)
entering state
remove from quarentine:DocumentId [doc_id=THIS IS A DOCUMENT ID 1234]
Hibernate: select processins0_.InstanceId as col_0_0_ from
ProcessInstanceInfo processins0_ where ? in (select eventtypes1_.element
from EventTypes eventtypes1_ where
processins0_.InstanceId=eventtypes1_.InstanceId)
VirusScanStatus [count=1, status=failed, unquarantineCount=3] sleeping:9000
Hibernate: select processins0_.InstanceId as col_0_0_ from
ProcessInstanceInfo processins0_ where ? in (select eventtypes1_.element
from EventTypes eventtypes1_ where
processins0_.InstanceId=eventtypes1_.InstanceId)
Hibernate: select processins0_.InstanceId as col_0_0_ from
ProcessInstanceInfo processins0_ where ? in (select eventtypes1_.element
from EventTypes eventtypes1_ where
processins0_.InstanceId=eventtypes1_.InstanceId)
entering state
remove from quarentine:DocumentId [doc_id=THIS IS A DOCUMENT ID 1234]
Hibernate: select processins0_.InstanceId as col_0_0_ from
ProcessInstanceInfo processins0_ where ? in (select eventtypes1_.element
from EventTypes eventtypes1_ where
processins0_.InstanceId=eventtypes1_.InstanceId)
Hibernate: select processins0_.InstanceId as col_0_0_ from
ProcessInstanceInfo processins0_ where ? in (select eventtypes1_.element
from EventTypes eventtypes1_ where
processins0_.InstanceId=eventtypes1_.InstanceId)
Hibernate: select variables0_.processInstanceId as processI5_1_,
variables0_.id as id1_, variables0_.name as formula1_1_, variables0_.id as
id4_0_, variables0_.name as name4_0_, variables0_.persister as
persister4_0_, variables0_.processInstanceId as processI5_4_0_,
variables0_.workItemId as workItemId4_0_, variables0_.entityClass as
entityCl7_4_0_, variables0_.entityId as entityId4_0_, variables0_.TYPE as
TYPE4_0_ from VariableInstanceInfo variables0_ where
variables0_.processInstanceId=?
Hibernate: select processins0_.InstanceId as col_0_0_ from
ProcessInstanceInfo processins0_ where ? in (select eventtypes1_.element
from EventTypes eventtypes1_ where
processins0_.InstanceId=eventtypes1_.InstanceId)
Hibernate: delete from EventTypes where InstanceId=?
Hibernate: delete from ProcessInstanceInfo where InstanceId=? and OPTLOCK=?
Hibernate: update SessionInfo set lastModificationDate=?, rulesByteArray=?,
startDate=?, OPTLOCK=? where id=? and OPTLOCK=?
finished
Here's my configuration:
orm.xml
--------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm orm_1_0.xsd"
version="1.0">
<named-query name="ProcessInstancesWaitingForEvent">
<query>
select
processInstanceInfo.processInstanceId
from
ProcessInstanceInfo processInstanceInfo
where
:type in elements(processInstanceInfo.eventTypes)
</query>
</named-query>
</entity-mappings>
persistance.xml
--------------------------------------
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<persistence version="1.0"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd
http://java.sun.com/xml/ns/persistence/orm
http://java.sun.com/xml/ns/persistence/orm_1_0.xsd"
xmlns:orm="http://java.sun.com/xml/ns/persistence/orm"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/persistence">
<persistence-unit name="org.drools.persistence.jpa">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>jdbc/TEST</jta-data-source>
<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.MySQL5Dialect" />
<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.jndi.class"
value="bitronix.tm.jndi.BitronixInitialContextFactory"/>
</properties>
</persistence-unit>
</persistence>
Calling Code
-------------------------------
public static final void main(String[] args) {
try {
createDataSource();
// load up the knowledge base
KnowledgeBase kbase = readKnowledgeBase();
// create the entity manager factory and register it in the
// environment
System.out.println("create entity manager");
System.setProperty(Context.INITIAL_CONTEXT_FACTORY,
"bitronix.tm.jndi.BitronixInitialContextFactory");
EntityManagerFactory emf = Persistence
.createEntityManagerFactory("org.drools.persistence.jpa");
Environment env = KnowledgeBaseFactory.newEnvironment();
env.set(EnvironmentName.ENTITY_MANAGER_FACTORY, emf);
env.set(Context.INITIAL_CONTEXT_FACTORY,
"bitronix.tm.jndi.BitronixInitialContextFactory");
env.set(EnvironmentName.TRANSACTION_MANAGER,TransactionManagerServices.getTransactionManager());
// create a new knowledge session that uses JPA to store the
runtime
// state
System.out.println("create jpa backed stateful ksession");
StatefulKnowledgeSession ksession = null;
if (ksession == null) {
ksession = JPAKnowledgeService
.newStatefulKnowledgeSession(kbase, null, env);
int sessionId = ksession.getId();
System.out.println("SESSIONID:" + sessionId);
Persister pes = new Persister();
pes.put(new Integer(sessionId));
}
// KnowledgeRuntimeLogger logger =
KnowledgeRuntimeLoggerFactory.newConsoleLogger(ksession);
KnowledgeRuntimeLogger logger = KnowledgeRuntimeLoggerFactory
.newFileLogger(ksession, "test");
ksession.insert(new DocumentId("THIS IS A DOCUMENT ID 1234"));
System.out.println("Starting Process...");
ksession.startProcess("VirusScan");
System.out.println("Fire All Rules...");
ksession.fireAllRules();
System.out.println("finished");
logger.close();
// ksession.dispose();
} catch (Throwable t) {
t.printStackTrace();
}
}
private static KnowledgeBase readKnowledgeBase() throws Exception {
KnowledgeBuilder kbuilder =
KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add(ResourceFactory.newClassPathResource("VirusScanner.drl",VirusScanStatus.class),
ResourceType.DRL);
kbuilder.add(ResourceFactory.newClassPathResource("VirusScan.rf",VirusScanStatus.class),
ResourceType.DRF);
KnowledgeBuilderErrors errors = kbuilder.getErrors();
if (errors.size() > 0) {
System.out.println("NUM:" + errors.size());
for (KnowledgeBuilderError error : errors) {
System.err.println("A_ERROR:" + error);
}
throw new IllegalArgumentException("Could not parse
knowledge.");
}
KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());
return kbase;
}
private static void createDataSource() {
System.out.println("creating datasource");
Configuration conf = TransactionManagerServices.getConfiguration();
conf.setServerId("jvm-1");
conf.setLogPart1Filename("./tx-logs/part1.btm");
conf.setLogPart2Filename("./tx-logs/part2.btm");
PoolingDataSource ds = new PoolingDataSource();
ds.setUniqueName("jdbc/TEST");
ds.setClassName("com.mysql.jdbc.jdbc2.optional.MysqlXADataSource");
ds.setMaxPoolSize(3);
ds.setAllowLocalTransactions(true);
ds.getDriverProperties().put("user", "jboss");
ds.getDriverProperties().put("password", "jboss");
ds.getDriverProperties().put("URL",
"jdbc:mysql://localhost:3306/jpadrools5");
ds.init();
}
Regards,
Lawrence
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/How-do-I-persist-at-e...
Sent from the Drools - User mailing list archive at Nabble.com.
14 years, 2 months
Strange Performance Problem in Rules
by ravibhatt
Hi all,
I have a rule that looks like below:
Rule "CheckSomeConditionRule"
When
$project:Project(status==STATUS_ENUM.DATA_FETCHED)
$rule:Rule(name=="CheckSomeConditionRule")
$processResult1:ProcessResult(projectId==$project.id, inputSource memberOf
$rule.inputTableList
, outputTable=="")
$processResult2:ProcessResult(projectId==$project.id, inputSource memberOf
$rule.inputTableList
inputSource!=$processResult1.inputSource,
this!=$processresult1, outputTable=="")
$processData1:ProcessData(parent==$processResult1)
$processData2:ProcessData(this!=$processData1,parent==$processResult2
,eval($processData2.getValue("a").equalsIgnoreCase($processData1.getValue("a")))
,eval($processData2.getValue("b").equalsIgnoreCase($processData1.getValue("b")))
Then
/////do important stuff here
end
I am trying to run this rule with two data set (represented by ProcessResult
class that holds several rows in terms of ProcessData objects), each data
set has 10000 records only. (In real usages, we will have atleast a million
records in both these data sets.)
I am inserting all of the rows i.e all rows represented in terms of
ProcessData objects. I am inserting some 20000+ objects to test this. While
inserting, first 10000 records are getting inserted fairly quickly, the next
10000 records are taking a lot of time.. in tunes of 15 -30 mins.
I understand that drools is trying to create activations as i insert facts
but this seems to be too slow. is it eval in my conditions that is making it
slower? or is it equalsIgnoreCase method? if i use == instead of
equalsIgnoreCase my rule never gets fired.
I am doing something wrong? please advice.
My data structure is inherently hierarchical:
ProcessResult (represnts a table)
contains
ProcessData (represents rows)
contains
list of Dimensions & list of Metrics (accessed via getValue()
method above)
Thanks in Advance,
Ravi
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Strange-Performance-P...
Sent from the Drools - User mailing list archive at Nabble.com.
14 years, 2 months
Rules Fest October 2010
by Mark Proctor
Rules Fest is in full swing, http://rulesfest.org/html/home.html.
Great attendance with around 100 people and great food :)
Myself, Edson and Davide are here. Davide did a great lunch time talk.
Kris will be arriving on Wednesday to help with the BootCamp.
It's been a lot of preparation last week and we'll be very busy this
week and next, so apologies if our responses aren't timely on mailing
lists and irc.
14 years, 2 months
Re: [rules-users] GWT Console and WSHT Rendering
by sam.squire@paretopartners.com
I have worked it out using the sourcecode.
To retrieve variables in forms from your process, you can use two
Freemarker variables:
- Task is for human task information fields. Take a look at the Task
class and the TaskData class to see what you can access from your
template.#
This way you can also get to your task metadata like:
${task.taskData.createdOn?datetime} would get the date the task was
created.
- Content is for your own mapped fields.
You will have to make a dataInputAssociaton that has the name of "Content"
and use a dataInputAssociation to provide it with a HashMap of the values
you want to be available in your template. The HashMap you put into
content is accessible by content.<keyName> from the template.
Is this the official way to do it or is there a better way?
Thanks.
Sam Squire
This message may contain confidential and privileged information and is intended solely for the use of the named addressee. Access, copying or re-use of the e-mail or any information contained therein by any other person is not authorised. If you are not the intended recipient please notify us immediately by returning the e-mail to the originator and then immediately delete this message. Although we attempt to sweep e-mail and attachments for viruses, we do not guarantee that either are virus-free and accept no liability for any damage sustained as a result of viruses.
Please refer to http://www.bnymellon.com/disclaimer/piml.html for certain disclosures.
14 years, 2 months
parallel folw execution
by borg
Hello,
I was trying to understand what would happen if several events/object of the
same type, which is used to start a flow, occur simultaneously or before
each flow execution they trigger would end.
Would i have several running instances of the flow for each trigger event?
Or would it wait turns to run each event/object through the same instance
sequentially?
As a practical example, one could imagine the typical loan approval example
and consider such events/objects the loan requests.
My point is exactly that each request does not affect the others (previous
or future) and as such they should all run in parallel (only limited because
of the paralelization capacity of the available resources).
Thanks
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/parallel-folw-executi...
Sent from the Drools - User mailing list archive at Nabble.com.
14 years, 2 months