3 Replies Latest reply on Jan 9, 2011 4:34 PM by Peter Horvath

    Removing history information of completed process instances

    Peter Horvath Newbie

      Hello All,

       

      Is there any way to remove the history of completed process instances from jBPM 4 history tables? I can't see any API function to achieve that. The retention of all process instance history information without any way of removing information about old, completed ones might lead to massive build-up in the long run. What do you think about this?

        • 1. Re: Removing history information of completed process instances
          Michael Holtzman Newbie

          We have a Purge by Date function, where we query JBPM_PROCESSINSTANCE for instances that have ended before a given retention date, and then delete the process instances returned by that query.

           

          We also modified jBPM's logging to restrict the type of log records that get generated (JBPM_LOG is the biggest disk hog of the bunch). For example, turning off variable update logging reduces the log table size and activity by about 50 percent.

          • 2. Re: Removing history information of completed process instances
            Michael Wohlfart Expert

            in jbpm4 the DbSessionImpl has a deleteProcessDefinitionHistory() method, you can use that as base for whatever history information you want to delete:

             

               List<HistoryProcessInstanceImpl> historyProcessInstances = session
                        .createCriteria(HistoryProcessInstanceImpl.class)
                        .add(Restrictions.eq("processDefinitionId", processDefinitionId))

                        .add(... insert random other Restriction here ...)

                        .list();

                // you also have to delete the activity since they have a foreign key relationship

                for (HistoryProcessInstanceImpl hpi : historyProcessInstances) {
                  List<HistoryActivityInstanceImpl> historyActivityInstances = session
                          .createCriteria(HistoryActivityInstanceImpl.class)
                          .add(Restrictions.eq("historyProcessInstance", hpi))
                          .list();
                  for (HistoryActivityInstanceImpl hai : historyActivityInstances) {
                    session.delete(hai);
                  }
                  session.delete(hpi);
                }

            • 3. Re: Removing history information of completed process instances
              Peter Horvath Newbie

              Hello Michael, thanks for your help.

               

              I think there should be a public API method to do this so I've created a JIRA: http://issues.jboss.org/browse/JBPM-2990