cancel
Showing results for 
Search instead for 
Did you mean: 

Question about some operations in a executionListener

jonlee
Champ in-the-making
Champ in-the-making
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
11 REPLIES 11

jonlee
Champ in-the-making
Champ in-the-making
my unit test also uses JTA , I do feel it's very strange too. It looks simple, but can't find it in the listener,  It's only two lines of code , one is start the process instance, another is find historic process instance by id

trademak
Star Contributor
Star Contributor
Hi,

Could you explain why you need the HistoricProcessInstance in the listener?
Can't you get the information from the DelegateExecution instance?

Best regards,