2 Replies Latest reply on Mar 12, 2013 12:42 PM by abuinigate

    Usage of ksession in Jbpm Spring Implementation

    abuinigate

      Hi,

       

      I am developing a web application which I will invoke a jbpm workflow. I am following a spring-jbpm integeration pattern to create a kbase,ksession etc.My question is how we have to use the ksession? Means for each request I have to create a seperate session(every process instance has unique session id ) or multiple process instances sharing the same ksession.

       

      Currently I am following a spring approach in which one session id shared between multiple process instances. How to change this behaviour to make it one session per process instance.Is there any way to do this in spring. I tried bean scope"prototype" which will not workout. and jbpm session tag not having the attribute scope.

       

      My XML is:

       

       

      <jbpm:kbase id="kbase">

          <jbpm:resources>

            <jbpm:resource type="BPMN2" source="classpath:Hello.bpmn" />

          </jbpm:resources>

        </jbpm:kbase>

       

      <jbpm:ksession id="ksession" type="stateful" kbase="kbase">

       

      <jbpm:configuration>

            <jbpm:jpa-persistence>

              <jbpm:entity-manager-factory ref="entityManagerFactory"/>

              <jbpm:transaction-manager ref="transactionManager"/>

            </jbpm:jpa-persistence>

           

          </jbpm:configuration>

      </jbpm:ksession>

      <bean id="ds" class="org.springframework.jdbc.datasource.DriverManagerDataSource">

      <property name="driverClassName" value="com.mysql.jdbc.Driver"></property>

      <property name="url" value="jdbc:mysql://localhost:3306/jbpmworkflow?autoReconnect=true"/>

      <property name="username" value="root"/>

      <property name="password" value="root"/>

      </bean>

       

      <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"

                        p:dataSource-ref="ds">

      <property name="persistenceXmlLocation" value="classpath:META-INF/persistence.xml" />

      <property name="persistenceUnitName" value="org.jbpm.persistence.jpa" />

       

      <property name="jpaVendorAdapter">

      <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">

      <property name="database" value="MYSQL"/>

      <property name="showSql" value="true"/>  

      <property name="databasePlatform" value="org.hibernate.dialect.MySQL5Dialect" />

      </bean>         

      </property>

      </bean>

       

       

       

      <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager" p:entityManagerFactory-ref="entityManagerFactory">

      <property name="dataSource" ref="ds"/>

      </bean>

       

       

       

      Waiting eagerly for your replies.

       

       

      --Abuthahir