JBPM DB clean up

2,730 views
Skip to first unread message

subasis mohanty

unread,
Mar 20, 2015, 12:10:03 PM3/20/15
to jbpm-...@googlegroups.com
Hi,

We use Oracle as a datasource with JBPM 6.2. Is there any API to clean all the tables that JBPM uses. We want to clean all the tables as there are certain human task, process instances which remains as stale objects in database.

Is there any generic way of cleaning/removing all the tasks, processinsatnce and workitems from JBPM database, as it might grow indefinitely.

Thanks & Regards,
Subhasish Mohanty

Suchi

unread,
Mar 20, 2015, 7:04:04 PM3/20/15
to jbpm-...@googlegroups.com
As far as I know, we can use "ant clean.db" to clean up all the database.

subasis mohanty

unread,
Mar 23, 2015, 9:40:47 AM3/23/15
to jbpm-...@googlegroups.com
"ant clean.db" is separate process, i would like to know if there are any JBPM API's that we can invoke and ask to clear records older that 2 days, 3 days,....

Maciej Swiderski

unread,
Mar 23, 2015, 9:50:00 AM3/23/15
to subasis mohanty, jbpm-...@googlegroups.com
take a look at this: Keep your jBPM environment healthy though it’s mainly about log/history data.

Maciej
--
You received this message because you are subscribed to the Google Groups "jBPM Usage" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jbpm-usage+...@googlegroups.com.
To post to this group, send email to jbpm-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jbpm-usage/c136b511-1ffd-44cc-b1ed-869ef60c1b36%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

subasis mohanty

unread,
Mar 24, 2015, 11:11:23 AM3/24/15
to jbpm-...@googlegroups.com, subasis...@gmail.com
Thanks Maciej, 
I am looking forward for any kind of JBPM API by which we can delete the run time JBPM tables for a date range i.e. Older than 2 days then delete everything, as for cleaning Audit Log tables JBPM provides API as mentioned in the you have sent.
 Thanks and appreciate your help

Maciej Swiderski

unread,
Mar 24, 2015, 12:46:50 PM3/24/15
to subasis mohanty, jbpm-...@googlegroups.com
Actually for that to work as you described you need to combine both audit/history data with jBPM runtime api. So you first query for process instances you’d like to remove/abort and then go over there result and call individual abortProcessInstance method of ksession.

Maciej

Maciej Swiderski

unread,
Mar 25, 2015, 8:10:49 AM3/25/15
to subasis mohanty, jbpm-...@googlegroups.com
yes, that is pretty much what it will take to achieve the described goal. Then not sure why would you like to perform such operation? If you don’t want to have process instances older than given time then design process definition like that - for example use event based subprocess with timer that will fire after given amount of time e.g. 2d for 2 days and will the cancel that process instance. With that you don’t have to remove any runtime data and only remaining part will be history logs.

Maciej
On 25 mar 2015, at 01:30, subasis mohanty <subasis...@gmail.com> wrote:

Hi Maciej,

As you said i need to query process instances, how do we do that is it simply calling getAllProcessInstances() of JpaAuditLog, then imagine if there are  100000 processinstancez then pulping alk these records and deleting this one by one might be a risky thing i.e. memory issues.
If you can help me in getting a API by which u can selectively choose process instances or delete all of those than that would be great

T

subasis mohanty

unread,
Mar 26, 2015, 1:32:16 PM3/26/15
to jbpm-...@googlegroups.com, subasis...@gmail.com
Thanks a lot Maciej 

Guru I

unread,
May 10, 2017, 3:58:11 PM5/10/17
to jBPM Usage, subasis...@gmail.com
Hi Maciej

I am trying to find out why my task data is deleted as soon as task state changed to Completed in 6.5.0, where as in 6.4.0 it doesnt. I looked at the article you said (and asked question there too) but i cant figure out where those configurations are. Basically we are solely using kie-server/container to deploy kjar and using REST side to progress the task. We would like to see the completed task/comments etc w/o actually deleting it. Why the behavior changed in 6.5.0 or the way it supposed to work?

Thanks
Guru

Maciej Swiderski

unread,
May 11, 2017, 1:11:25 AM5/11/17
to Guru I, jBPM Usage, subasis mohanty
First of all, there is no feature that would remove task after only task completion. There is one that cleans up db after process instance was completed - that removes all tasks that belong to that process instance.
Though as far as I know this was not in community 6.5.0.Final but was added afterwards so you might only have this if you run on BPMS product. If so you can disable it by setting following system property:

-Dorg.jbpm.task.cleanup.enabled=false

Maciej

To unsubscribe from this group and stop receiving emails from it, send an email to jbpm-usage+unsubscribe@googlegroups.com.

To post to this group, send email to jbpm-...@googlegroups.com.

Guru I

unread,
May 11, 2017, 4:35:01 PM5/11/17
to jBPM Usage, guru.i...@gmail.com, subasis...@gmail.com
Thank you for that parameter Maciej!, yes it happens when process is completed. I realized that after i posted here. And yes i was using jbpm version but later moved to redhat. 
Something worth mentioning as you suggested it is System property, I added it in my standalone-full config, but it didn't work. I also saw that redhat mention the same here

So after decompiling the kie-server war I saw JbpmKieServerExtension.class#createContainer()… is using this parameter to control the life cycle event. But interestingly its doing so on container properties and not System properties
     KieServerConfig config = new KieServerConfig(kieContainerInstance.getResource().getConfigItems());
if (config.getConfigItemValue("org.jbpm.task.cleanup.enabled", "true").equalsIgnoreCase("true"))
      {
        logger.debug("Registering TaskCleanUpProcessEventListener");
        addTaskCleanUpProcessListener(unit, kieContainer);
      }


So the way i was able to make it work is by creating container using rest-api call kie-server/services/rest/server/config and pass body with 

...

<container container-id="TestContainer">

<config-items>

    <itemName>org.jbpm.task.cleanup.enabled</itemName>

    <itemValue>false</itemValue>

    </config-items>

...


Although i really like this part of my kmodule.xml which is currently empty like this..?
 
<kmodule xmlns="http://jboss.org/kie/6.0.0/kmodule">
</kmodule>

Maciej Swiderski

unread,
May 12, 2017, 1:12:48 AM5/12/17
to Guru I, jBPM Usage, subasis mohanty
Ah correct, that was fixed on version 7 only to use system properties. You can workaround this by editing the server state file that is usually in the WILDFLY_HOME/bin directory and it's named with {kie-server-id}.xml. You can just add there this config item to disable task cleanup listener.

Maciej

To unsubscribe from this group and stop receiving emails from it, send an email to jbpm-usage+unsubscribe@googlegroups.com.

To post to this group, send email to jbpm-...@googlegroups.com.

Guru I

unread,
May 15, 2017, 12:59:33 PM5/15/17
to jBPM Usage, guru.i...@gmail.com, subasis...@gmail.com
Hi Maciej - Thank you for response, but adding this config to my existing container (created via Business-Central) in my {kie-server-id}.xml in jboss eap doesnt work, the new config-item gets wiped everytime i restart jboss, or if I create new on via REST its again get cleared the same way. 
Any idea on how to make it persist?

Thanks
guru

Guru I

unread,
May 15, 2017, 1:04:35 PM5/15/17
to jBPM Usage, guru.i...@gmail.com, subasis...@gmail.com
or if I create new on via REST its again get cleared the same way.  - What I meant is entire container is wiped out  when i restart 

Maciej Swiderski

unread,
May 15, 2017, 1:51:16 PM5/15/17
to Guru I, jBPM Usage, subasis...@gmail.com
that config item should be on the server level and not container, like this:


<kie-server-state>
...
  <configuration>
    <configItems>
      <config-item>
        <name>org.jbpm.task.cleanup.enabled</name>
        <value>false</value>
        <type>java.lang.Boolean</type>
      </config-item>
  </configuration>
  <containers>
    <container>
...
Maciej

Guru I

unread,
May 15, 2017, 2:13:59 PM5/15/17
to jBPM Usage, guru.i...@gmail.com, subasis...@gmail.com
This is exactly i had it before (sorry forgot to add above post) but it didnt work, the only way it works is when I have it on container level. But then it gets wiped out on every restart. sorry if i am missing something here..

This is how it looks currently in my env.

<kie-server-state>
  <controllers>
  </controllers>
  <configuration>
    <configItems>
      <config-item>
        <name>org.jbpm.task.cleanup.enabled</name>
        <value>false</value>
        <type>java.lang.Boolean</type>
      </config-item>
      <config-item>

The way i see it here in decompiled jar
 KieServerConfig config = new KieServerConfig(kieContainerInstance.getResource().getConfigItems());
...
if (config.getConfigItemValue("org.jbpm.task.cleanup.enabled", "true").equalsIgnoreCase("true")) <=== Is this on container level then ..see below 
so 
public KieServerConfig(List<KieServerConfigItem> configItems)
  {
    if (configItems != null) {
      this.configItems = configItems; // overwriteen???
    }
  }

Maciej Swiderski

unread,
May 17, 2017, 3:52:47 AM5/17/17
to Guru I, jBPM Usage, subasis...@gmail.com
looks like a bug… for sure it’s fixed on later versions but you might get this through RedHad support channel to be fixed in 6.4 version as well.

Maciej

Guru I

unread,
May 17, 2017, 9:04:28 AM5/17/17
to jBPM Usage, guru.i...@gmail.com, subasis...@gmail.com
Yes and thank you for confirming and replying with parameters help.

Tarun S

unread,
Sep 13, 2018, 8:35:03 AM9/13/18
to jBPM Usage
Hi Maciej,

Good day, 
I am using RHPAM 7.x version with kie 7.7.x and still facing the error of container getting wiped out after a restart.
I create containers using kie - REST calls and get wiped immediately after a restart.
Is there any fix to address the issue.

Looking forward.

Cheers,
Tarun 

Maciej Swiderski

unread,
Sep 13, 2018, 3:12:16 PM9/13/18
to Tarun S, jBPM Usage
Describe what you do and what is the actual problem. Without this it’s really difficult to say what might be the issue…

Maciej

--
You received this message because you are subscribed to the Google Groups "jBPM Usage" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jbpm-usage+...@googlegroups.com.
To post to this group, send email to jbpm-...@googlegroups.com.

Tarun S

unread,
Sep 14, 2018, 4:02:59 AM9/14/18
to jBPM Usage
Hi Maciej,

I imported kjar into my local jboss bpm environment and deployed the kjar using KIE REST calls:  [PUT] - /server/containers/{id}.
Container got created and able to create process instances as well (headless). But when jboss bpm got restarted, whatever the containers that got created through REST calls got wiped out . Only containers are present which is created and deployed in kie workbench.

Am I missing configuration .

Below is the request body I sent to create a container.

<kie-container container-alias="My_project"  container-id="My_project_1.0.1">
  <config-items>
                <itemName>KBase</itemName>
                <itemValue></itemValue>
                <itemType>BPM</itemType>
            </config-items>
            <config-items>
                <itemName>KSession</itemName>
                <itemValue></itemValue>
                <itemType>BPM</itemType>
            </config-items>
            <config-items>
                <itemName>MergeMode</itemName>
                <itemValue>MERGE_COLLECTIONS</itemValue>
                <itemType>BPM</itemType>
            </config-items>
            <config-items>
                <itemName>RuntimeStrategy</itemName>
                <itemValue>PER_PROCESS_INSTANCE</itemValue>
                <itemType>BPM</itemType>
            </config-items>
  <release-id>
    <artifact-id>My_project</artifact-id> 
    <group-id>com.myteam</group-id>
    <version>1.0.1</version> 
  </release-id> 
  </kie-container>

Looking forward to hear from you.

Cheers,
Tarun

Maciej Swiderski

unread,
Sep 14, 2018, 7:03:29 AM9/14/18
to Tarun S, jBPM Usage
So this is expected behaviour if your kie server is running in managed mode - meaning is connected to workbench. If so then you should use controller (either UI or REST) to deploy containers and not the kie server rest api.

Maciej

Tarun S

unread,
Nov 16, 2018, 12:34:01 AM11/16/18
to jBPM Usage
Thanks a lot Maciej, that helped.

Mca Group

unread,
Nov 21, 2018, 3:10:28 AM11/21/18
to jBPM Usage
Good Day Subasis Mohanty,

I am started working on JBPM platform. I am looking for any API to Clean all the Mysql Database tables. I am using JBPM v7.3.0  and Mysql v5.7.24.

Thanks,
Srikanth

Bala

unread,
Nov 21, 2018, 4:54:37 AM11/21/18
to Mca Group, jBPM Usage
Here's an approach [1] that I used sometime back to clean up all jbpm database tables. However, the easiest option is to simply drop and recreate the database schema using the DDL scripts


--
You received this message because you are subscribed to the Google Groups "jBPM Usage" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jbpm-usage+...@googlegroups.com.
To post to this group, send email to jbpm-...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages