learner
learner

Reputation: 950

JBPM : How to Listen Once ResourceChangeScanner Modifies the package after Changes

I want to upgrade my process instances using WorkflowProcessInstanceUpgrader. To trigger the upgrade after any change I wanted to listen for changes completed by ResourceChangeScanner. To listen the completion of changes I was looking to configure KnowledgeBaseEventListener. I have drools-spring-integration in place which uses drools-spring.xsd to configure beans and event listeners. I am getting KBase and Ksession from spring. I was trying to register my KnowledgeBaseEventListener in my spring configurations. But, The issue is that drools-spring.xsd only registers 3 kind of listeners 1. ProcessEventListener 2. AgendaEventListener 3. WorkingMemoryEventListener

Solution Required : 1. I need to know how to configure the KnowledgeBaseEventListener in my spring configurations ? Example for ksession we have following config to register listeners.

                 <drools:ksession id="knowledgeSession" type="stateful" kbase="knowledgeBase">
                        <drools:agendaEventListener ref="agendaEventListener"/>
                        <drools:workingMemoryEventListener ref="wmEventListener"/>

  1. Is this the best place to trigger a batch process upgrade ? From within the KBaseEventListener ?
  2. Shall I add KBaseEventListener using knowledgebase.addEventListener() ?

Environment 1. Drools-5.5.0.Final a. Guvnor b. Jbpm

Upvotes: 0

Views: 129

Answers (1)

eze
eze

Reputation: 2422

One way to get complete control is to create the ksession yourself in java. (below I insert it into the context with a factory bean):

  <bean id="ksessionInit" class="my.com.KSessionInitializer">
      <constructor-arg index="0"><ref bean="jpaEMF"/></constructor-arg>
      <constructor-arg index="0"><ref bean="txMgr"/></constructor-arg>
      <constructor-arg index="0"><ref bean="kagent"/></constructor-arg>
      <constructor-arg index="0"><ref bean="node1"/></constructor-arg>
  </bean>
  <bean id="ksession1" factory-bean="ksessionInit" factory-method="getKsession"/>

Here the KSessionInitializer constructor does all the work: sets the EMFactory and TXmanager; adds event listeners; and, inserts the ksession in the node, like:

  anode.set("ksession1",ksession);

in my case I am using JPAKnowledgeService, so to get the ksession i do a:

  ksession=JPAKnowledgeService.loadStatefulKnowledgeSession(sessionid, kAgent.getKnowledgebase(),null,etc);

-hth J

Upvotes: 0

Related Questions