3 Replies Latest reply on Dec 9, 2014 2:07 AM by Maciej Swiderski

    WORKITEMINFO table is not getting filled

    Santhosh Bhat Newbie

      Hi,

       

      I was reading the chapter - Chapter 8. Core Engine: Persistence and transactions  , and I found that the following code can be used to persist the process state. I want to use the persisted information to rehydrate the process, in case of crash/error (as explained in the thread - https://developer.jboss.org/thread/167105 )

       

       

      8.1.3.3. Manually configuring the engine to use persistence

       

      You can also use the JPAKnowledgeService to create your knowledge session. This is slightly more complex, but gives you full access to the underlying configurations. You can create a new knowledge session usingJPAKnowledgeService based on a knowledge base, a knowledge session configuration (if necessary) and an environment. The environment needs to contain a reference to your Entity Manager Factory. For example:

      // create the entity manager factory and register it in the environment 
      EntityManagerFactory emf =
          Persistence.createEntityManagerFactory( "org.jbpm.persistence.jpa" );
      Environment env = KnowledgeBaseFactory.newEnvironment();
      env.set( EnvironmentName.ENTITY_MANAGER_FACTORY, emf ); 
      // create a new knowledge session that uses JPA to store the runtime state
      StatefulKnowledgeSession ksession =
          JPAKnowledgeService.newStatefulKnowledgeSession( kbase, null, env );
      int sessionId = ksession.getId(); 
      // invoke methods on your method here
      ksession.startProcess( "MyProcess" );
      ksession.dispose();

       

       

      Using the code, I can see the data in ProcessInstanceLog table, and  SessionInfo table, but the WorkItemInfo table is always empty. I am using PostgreSQL DB. Please let me know what is wrong here?

       

      Yes, I also tried

       

      new JPAWorkingMemoryDbLogger(ksession);


      And I also have <class>org.drools.persistence.info.WorkItemInfo</class> in my persistence.xml

       

      after creating the session, but did not work for me.

       

      About my workflow

       

      My workflow is something like this [ start --> task1 --> task2 --> .... task-99 --> task 100 --> end], where each task is a "Domain specific Custom task" backed by WorkItemHandler implementation.

        • 1. Re: WORKITEMINFO table is not getting filled
          Maciej Swiderski Master

          is your domain specific task a wait state task? Meaning do you call completeWorkItem method within the execute method of the handler? If so then work item info will not contain any data as there is no need to persist it. You can enable hibernate sql logging to see what sort of queries are produced. WorkItemInfo table is populated only if the work items are asynchronous - try adding user task to your process and then you should see entries in that table.

           

          HTH

          • 2. Re: WORKITEMINFO table is not getting filled
            Santhosh Bhat Newbie

            Hi   thank you for your answer. I have couple of questions here

             

            To understand more, if a workItem task takes longer than a configured time (some time configured within JBPM framework) , then it gets persisted into the DB ?

            and the second question, is there anyway I can FORCE the persistence of a workItemTask ? by means of an API call or something?

            • 3. Re: WORKITEMINFO table is not getting filled
              Maciej Swiderski Master

              persistence of work items is not based on time, it's based on their type so to say. So if you create work item handler then:

              • if you call completeWorkItem method as part of executeWorkItem then it won't be persisted
              • if you don't call completeWorkItem method as part of executeWorkItem then work item will be persisted in db and will wait for a signal to complete it and move on with process

              So invoking or not completeWorkItem method is the API to trigger persistence of the work item.

               

              HTH

              1 of 1 people found this helpful