Best performing way to process facts in a particular order?
by jkrupka
I've been trying to optimize our stateful rules to run a bit faster,
currently they can't quite keep up with the events coming into the session.
A lot of our rules have to find the fact whose attribute is the
smallest/largest value of all the facts of that type in working memory. I
had originally written the rules to do a min accumulate to find the min
value of the attribute, then a regular pattern to find the actual fact with
that min value. Some of the fact types actually have two fields that must
be used to find the min - think of them as a category and a score. For
those I did two accumulate mins, one to find the lowest category, one to
find the lowest score in that category, and then a third rule to find the
fact with that min category and min score.
I recently refactored all the rules to use the paradigm of one rule that
matches the fact type I'm interested in, and a second rule that uses the not
operator to express that there be no facts whose attribute is a higher value
than the fact I just matched. In the contrived test I wrote, this seemed to
perform better, but it's hard to tell if they are performing better or not
with production data flowing through them.
I know of a third option - writing my own accumulate functions - which I
will probably try next. This should allow me to find the min/max fact with
just one iteration over the facts, vs multiple iterations like my first
approach. I don't know how it will compare to using the exists method
though.
Any feedback on these three different approaches? Any other ideas on the
best way to do this?
--
View this message in context: http://drools.46999.n3.nabble.com/Best-performing-way-to-process-facts-in...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 6 months
Rules Flow Eclipse editor
by Prafull Kumar
Hi All,
I would like to know how we can modify the Rules flow eclipse editor look and
feel and functionality. e.g. If we have a Embedded Sub-Process in the flow and
reduce the size of it, the arrows are still displayed in the main canvas. Please
see the attached snapshot for reference.
How we can fix it? also if we want to open the Embedded Sub-Process in a new
window for easy maintainability/readability of the very complex processes, how
we can achieve it?
Going forward we are also looking to create the custom editor for the nodes.
Please guide us if its possible and there is any document for this.
Note: It seems that I can not attach files in the mailing list. Let me know if
its possible to share the image.
Regards, Prafull
13 years, 6 months
typical rules application
by Abhay B. Chaware
Hi
I am just trying to get a feel of size of a typical rules application. How many low-to-medium complex rules a typical rules application will have ? I understand and agree that it totally depends upon the application and business needs, but I am trying to get a feel of if rules is the correct solution to a problem and if that can be determined by number of rules.
e.g.
if to satisfy a business need, I wrote a rules application and ended up writing say 20 medium-complex rules and in another case, I wrote a rules application and ended up writing say 10,000 low/medium complex rules
which one of these two cases sound like real, logical candidate for a rules based app and why ? Is there a rule of thumb, that "x" number of rules is a good number for an application to qualify under rules technology ?
-abhay
13 years, 6 months
DSL in Drools 5.2
by Saleem Lakhani
Can we combine to different DSL rules in DSLR with a Boolean operator?
Can we combine them with an OR or AND?
e.g; in DSL I have:
a or b = Person(name ==a || name ==b)
c or d= Person(name==c || name ==d)
Can I write in DRL as:
a or b or c or d?
I know combining them as one rule is easier but I have few limitations;
saleem
13 years, 6 months
Deploying Guvnor on a existing repository DB
by maav
Hi!
I'm trying to get Guvnor to deploy on a pre-existing existing DB. The use
case beeing that we wan't to be able to bring up a backup instance of guvnor
in case the primary goes down.
But if a deploy guvnor on a "fresh" DB schema all tables get created along
with trigger and sequences (using Oracle 11).
But when I un-deploy guvnor.war and remove the repository-folder and then
deploy it again I get the following exception:
Caused by: java.sql.SQLException: ORA-00001: unique constraint
(ID_VERIFICATION.G_DEFAULT_BUNDLE_IDX) violated
at
oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:331)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:288)
at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:745)
at
oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:219)
at
oracle.jdbc.driver.T4CPreparedStatement.executeForRows(T4CPreparedStatement.java:970)
at
oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1190)
at
oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3370)
at
oracle.jdbc.driver.OraclePreparedStatement.execute(OraclePreparedStatement.java:3476)
at
org.apache.jackrabbit.core.persistence.bundle.ConnectionRecoveryManager.executeStmtInternal(ConnectionRecoveryManager.java:371)
at
org.apache.jackrabbit.core.persistence.bundle.ConnectionRecoveryManager.executeStmtInternal(ConnectionRecoveryManager.java:298)
at
org.apache.jackrabbit.core.persistence.bundle.ConnectionRecoveryManager.executeStmt(ConnectionRecoveryManager.java:261)
at
org.apache.jackrabbit.core.persistence.bundle.ConnectionRecoveryManager.executeStmt(ConnectionRecoveryManager.java:239)
at
org.apache.jackrabbit.core.persistence.bundle.BundleDbPersistenceManager.storeBundle(BundleDbPersistenceManager.java:1207)
... 59 more
What do I need to do to prevent this?
This is my repository.xml:
<?xml version="1.0"?>
<!DOCTYPE Repository
PUBLIC "-//The Apache Software Foundation//DTD Jackrabbit
2.0//EN"
"http://jackrabbit.apache.org/dtd/repository-2.0.dtd">
<Repository>
<FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
</FileSystem>
<DataStore class="org.apache.jackrabbit.core.data.FileDataStore">
</DataStore>
<Security appName="Jackrabbit">
<SecurityManager
class="org.apache.jackrabbit.core.security.simple.SimpleSecurityManager"
workspaceName="security">
</SecurityManager>
<AccessManager
class="org.apache.jackrabbit.core.security.simple.SimpleAccessManager">
</AccessManager>
<LoginModule
class="org.apache.jackrabbit.core.security.simple.SimpleLoginModule">
</LoginModule>
</Security>
<Workspaces rootPath="${rep.home}/workspaces"
defaultWorkspace="default"/>
<Workspace name="${wsp.name}">
<FileSystem class="org.apache.jackrabbit.core.fs.db.OracleFileSystem">
</FileSystem>
<PersistenceManager
class="org.apache.jackrabbit.core.persistence.bundle.OraclePersistenceManager">
</PersistenceManager>
<SearchIndex
class="org.apache.jackrabbit.core.query.lucene.SearchIndex">
</SearchIndex>
</Workspace>
<Versioning rootPath="${rep.home}/version">
<FileSystem
class="org.apache.jackrabbit.core.fs.db.OracleFileSystem">
</FileSystem>
<PersistenceManager
class="org.apache.jackrabbit.core.persistence.bundle.OraclePersistenceManager">
</PersistenceManager>
</Versioning>
<SearchIndex
class="org.apache.jackrabbit.core.query.lucene.SearchIndex">
</SearchIndex>
</Repository>
--
View this message in context: http://drools.46999.n3.nabble.com/Deploying-Guvnor-on-a-existing-reposito...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 6 months
Drools flow persistence with Oracle, error enlisting a JdbcConnectionHandle of a JdbcPooledConnection from datasource jdbc/DBD02 in state ACCESSIBLE wrapping oracle.jdbc.xa.client.OracleXAConnection@1de2b1 on oracle.jdbc.driver.OracleConnection@dee38
by loumimi
I'm trying to persist my workflow into an Oracle db, when I tried to create
the session
StatefulKnowledgeSession ksession =
JPAKnowledgeService.newStatefulKnowledgeSession( kbase, null, env );
I have the exception bellow
Hibernate: select hibernate_sequence.nextval from dual
May 12, 2011 2:14:09 PM org.hibernate.util.JDBCExceptionReporter
logExceptions
WARNING: SQL Error: 0, SQLState: null
May 12, 2011 2:14:09 PM org.hibernate.util.JDBCExceptionReporter
logExceptions
SEVERE: error enlisting a JdbcConnectionHandle of a JdbcPooledConnection
from datasource jdbc/DBD02 in state ACCESSIBLE wrapping
oracle.jdbc.xa.client.OracleXAConnection@1de2b1 on
oracle.jdbc.driver.OracleConnection@dee38
java.lang.RuntimeException: Could not commit session
at
org.drools.persistence.session.SingleSessionCommandService.<init>(SingleSessionCommandService.java:119)
at
org.drools.persistence.jpa.impl.JPAKnowledgeServiceProviderImpl.newStatefulKnowledgeSession(JPAKnowledgeServiceProviderImpl.java:44)
at
org.drools.persistence.jpa.JPAKnowledgeService.newStatefulKnowledgeSession(JPAKnowledgeService.java:93)
at com.sample.ProcessTest.main(ProcessTest.java:61)
Caused by: javax.persistence.PersistenceException:
org.hibernate.exception.GenericJDBCException: could not get next sequence
value
at
org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:614)
at
org.hibernate.ejb.AbstractEntityManagerImpl.persist(AbstractEntityManagerImpl.java:226)
at
org.drools.persistence.session.SingleSessionCommandService.<init>(SingleSessionCommandService.java:107)
... 3 more
Caused by: org.hibernate.exception.GenericJDBCException: could not get next
sequence value
at
org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:126)
at
org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:114)
at
org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
at org.hibernate.id.SequenceGenerator.generate(SequenceGenerator.java:119)
at
org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:122)
at
org.hibernate.ejb.event.EJB3PersistEventListener.saveWithGeneratedId(EJB3PersistEventListener.java:49)
at
org.hibernate.event.def.DefaultPersistEventListener.entityIsTransient(DefaultPersistEventListener.java:154)
at
org.hibernate.event.def.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:110)
at
org.hibernate.event.def.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:61)
at org.hibernate.impl.SessionImpl.firePersist(SessionImpl.java:645)
at org.hibernate.impl.SessionImpl.persist(SessionImpl.java:619)
at org.hibernate.impl.SessionImpl.persist(SessionImpl.java:623)
at
org.hibernate.ejb.AbstractEntityManagerImpl.persist(AbstractEntityManagerImpl.java:220)
... 4 more
Caused by: java.sql.SQLException: error enlisting a JdbcConnectionHandle of
a JdbcPooledConnection from datasource jdbc/DBD02 in state ACCESSIBLE
wrapping oracle.jdbc.xa.client.OracleXAConnection@1de2b1 on
oracle.jdbc.driver.OracleConnection@dee38
at
bitronix.tm.resource.jdbc.JdbcConnectionHandle.enlistResource(JdbcConnectionHandle.java:61)
at
bitronix.tm.resource.jdbc.JdbcConnectionHandle.prepareStatement(JdbcConnectionHandle.java:200)
at
org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:534)
at
org.hibernate.jdbc.AbstractBatcher.prepareSelectStatement(AbstractBatcher.java:145)
at org.hibernate.id.SequenceGenerator.generate(SequenceGenerator.java:96)
... 13 more
Caused by: bitronix.tm.internal.BitronixSystemException: cannot enlist an
XAResourceHolderState with uniqueName=jdbc/DBD02
XAResource=oracle.jdbc.xa.client.OracleXAResource@1790581 with XID a
Bitronix XID [3138342E35312E31362E3232300000012FE420DBC400000000 :
3138342E35312E31362E3232300000012FE420DC5100000002], error=XAER_PROTO
at
bitronix.tm.BitronixTransaction.enlistResource(BitronixTransaction.java:83)
at
bitronix.tm.resource.common.TransactionContextHelper.enlist(TransactionContextHelper.java:267)
at
bitronix.tm.resource.common.TransactionContextHelper.enlistInCurrentTransaction(TransactionContextHelper.java:49)
at
bitronix.tm.resource.jdbc.JdbcConnectionHandle.enlistResource(JdbcConnectionHandle.java:59)
... 17 more
Caused by: javax.transaction.xa.XAException
at
oracle.jdbc.xa.OracleXAResource.disallowLocalTxnMode(OracleXAResource.java:1045)
at oracle.jdbc.xa.client.OracleXAResource.start(OracleXAResource.java:153)
at
bitronix.tm.internal.XAResourceHolderState.start(XAResourceHolderState.java:179)
at bitronix.tm.internal.XAResourceManager.enlist(XAResourceManager.java:89)
at
bitronix.tm.BitronixTransaction.enlistResource(BitronixTransaction.java:76)
... 20 more
Here is my configuration :
the code :
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add(ResourceFactory.newClassPathResource("ruleflow.rf"),
ResourceType.DRF);
KnowledgeBuilderErrors errors = kbuilder.getErrors();
if (errors.size() > 0) {
for (KnowledgeBuilderError error: errors) {
System.err.println(error);
}
throw new IllegalArgumentException("Could not parse
knowledge.");
}
KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());
configureDataSource();
// create the entity manager factory and register it in the
environment
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() );
// create a new knowledge session that uses JPA to store the runtime
state
StatefulKnowledgeSession ksession =
JPAKnowledgeService.newStatefulKnowledgeSession( kbase, null, env );
public static void configureDataSource()
{
PoolingDataSource ds = new PoolingDataSource();
ds.setUniqueName("jdbc/DBD02");
ds.setClassName("oracle.jdbc.xa.client.OracleXADataSource");
ds.setMaxPoolSize(3);
ds.setAllowLocalTransactions(true);
ds.getDriverProperties().put("user", "xxx");
ds.getDriverProperties().put("password", "xxx");
ds.getDriverProperties().put("URL",
"jdbc:oracle:thin:@gfxdevdb01.fr.world.xxx:1567:DBD02");
ds.init();
}
the persistence.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"
transaction-type="RESOURCE_LOCAL" >
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>jdbc/DBD02</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>
<properties>
<property name="hibernate.dialect"
value="org.hibernate.dialect.Oracle10gDialect"/>
<property name="hibernate.connection.driver_class"
value="oracle.jdbc.OracleDriver"/>
<property name="hibernate.connection.autocommit" value="true" />
<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"/>
</properties>
</persistence-unit>
</persistence>
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>
Do you have any idea about this problem ?
Thanks,
Regards,
--
View this message in context: http://drools.46999.n3.nabble.com/Drools-flow-persistence-with-Oracle-err...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 6 months