[rules-users] [Drools Flow 5.1] persistence + spring + localTransaction

anton.litvinenko anton.litvinenko at gmail.com
Wed May 25 15:16:17 EDT 2011


Greg, were you able to achieve process persistence in other configurations?
(e.g. without spring?) 

I don't use drools-spring bean factories to instantiate KnowledgeAgent and
KnoweldgeBase (instead i created alternative factories) + the following JPA
definition and spring context

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">
        <provider>org.hibernate.ejb.HibernatePersistence</provider>
        <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.SerializablePersistedVariable</class>
       
<class>org.drools.persistence.processinstance.variabletypes.JPAPersistedVariable</class>
        <properties>
            <property name="hibernate.dialect"
value="org.hibernate.dialect.PostgreSQLDialect"/>
            <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.connection.autocommit" value="false"/>
        </properties>
    </persistence-unit>
</persistence>

ApplicationContext.xml:
    <bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
        <property name="dataSource" ref="dataSource"/>
        <property name="loadTimeWeaver">
            <bean
class="org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver"/>
        </property>
    </bean>

    <jee:jndi-lookup id="dataSource" jndi-name="jdbc/flowengine"/>

    <bean id="transactionManager"
class="org.springframework.orm.jpa.JpaTransactionManager">
        <constructor-arg type="javax.persistence.EntityManagerFactory"
ref="entityManagerFactory"/>
    </bean>

    <tx:annotation-driven transaction-manager="transactionManager"/>

This kinda works, but I have to start transaction manually before invoking
any method on Drools Flow. And of course if an exception happens during the
invocation then everything is rolled back (e.g. process with 3 steps and the
last step crashes then process state in database is not updated with 2 first
steps).

Is it possible to configure Drools Flow to start/commit transaction at
before/after process step?

--
View this message in context: http://drools.46999.n3.nabble.com/Drools-Flow-5-1-persistence-spring-localTransaction-tp2875263p2985689.html
Sent from the Drools: User forum mailing list archive at Nabble.com.



More information about the rules-users mailing list