AnsweredAssumed Answered

Question about some operations in a executionListener

Question asked by jonlee on May 30, 2014
Latest reply on Jun 5, 2014 by jonlee
I have a service bean through transaction proxy, there is a method like this:


   @Transactional
   @Component("myServiceBean")
   public MyServiceBean{
  
   }




   public void doSomething() throws RuntimeException{
      taskService.complete("101");
   }


My process definition has a executionListener, when some tasks complete, it will be fired, My listener like this:

  
   @Transactional
   @Component("CaseAcceptEndListener")
   public class CaseAcceptEndListener implements ExecutionListener{
   
        @Override
   public void notify(DelegateExecution delegateexecution) throws Exception {
           ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("myKey");

           HistoricProcessInstance hp =
         historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstance.getId())
         .singleResult();
          
        }

   }



In my listener, at first I start a another process, and then I query a historicProcessInstance by the process id just happended. but something is wrong, because I can't find the historyProcess. it seems like the codes  in different transaction.


use the same code(notify code) in my unit test, I can find the historyProcess, like this:

   @Test
   public void test(){
      ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("myKey");

       HistoricProcessInstance hp =
         historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstance.getId())
         .singleResult();
   }



so, can you give me some advices?  thanks very much

Outcomes