1 Reply Latest reply on Jun 18, 2009 7:37 PM by Alejandro Guizar

    Deleting a ProcessInstance in jBPM 3

    Josh Long Newbie

      apologies if this is spam. I sent it to the forum mailing address but it didnt seem like it took, so i suspect i Have to post here instead. Anyway, apologies:


      I'm wondering if there's any recipes for deleting a ProcessInstance
      from the DBMS in jBPM 3?

      I realize that it's, essentially, just a Hibernate object graph and
      that tailing through and scorching the earth on all the foreign keys,
      as I would with any Hibernate model, ought to do it.. Having said
      that, I'd love to avoid doing it if somebody else has already dealt
      with it, because it seems awfully hairy from where I'm sitting :-)

      Is there some hidden API method unnoticed? Basically, as processes
      finish, I (almost ) have a trigger that will automatically check to
      see if the node that was just finished is the last for the process
      instance and it inserts a record into an audit table, so that I can
      easily verify process X was run for customer X with variables 1,2, and
      3. I then want to purge the process instance itself from the database.
      Any ideas? Is this best handled from Java or from the DBMS? I like the
      idea of handling it from Java since its more easily "read" for a Java
      dev, plus, it's still transactional, and may not be that much slower

      Issues I can imagine are basically, what happens in the case of
      concurrences, or subprocesses? If I create a concurrence and that in
      turn forks 10 subprocesses, and one of the 10 subprocesses finishes, i
      want it to try and delete itself. When all 10 subprocesses have
      finished, the super process (the creator of the subprocesses) should
      evaluate that it has no outstanding branches and then try and delete
      itself. You see?


        • 1. Re: Deleting a ProcessInstance in jBPM 3
          Alejandro Guizar Master

          Try JbpmContext.getGraphSession().deleteProcessInstance(). It will take care of everything. Variables, task instances, subprocess instances and logs. Make sure you use a recent version of jBPM. In earlier versions some corner cases were not covered.

          Deleting a process instance is a rather complex operation. You'd be better off scheduling a periodic task which queried for and deleted ended process instances. Otherwise the deletion will disrupt your online operation.