Saturday, 30 December 2017

How to purge BPEL process instances manually?

Please follow the steps below to purge BPEL instances.
1. Make a back up of your dehydration store.
2. Create the script purge_instances.sql 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
CREATE OR REPLACE PROCEDURE purge_instances (p_older_than IN TIMESTAMP)
AS
   CURSOR c_cube_instance (p_date TIMESTAMP)
   IS
      SELECT cikey
        FROM cube_instance
       WHERE state >= 5 AND modify_date < p_date;
   CURSOR c_invoke_message (p_date TIMESTAMP)
   IS
      SELECT message_guid
        FROM invoke_message
       WHERE state > 1 AND receive_date < p_date;
   CURSOR c_dlv_message (p_date TIMESTAMP)
   IS
      SELECT message_guid
        FROM dlv_message
       WHERE state > 1 AND receive_date < p_date;
BEGIN
   -- Delete all closed instances older than specified date
   --
   FOR r_cube_instance IN c_cube_instance (p_older_than)
   LOOP
      collaxa.delete_ci (r_cube_instance.cikey);
   END LOOP;
   -- Purge all handled invoke_messages older than specified date
   --
   FOR r_invoke_message IN c_invoke_message (p_older_than)
   LOOP
      DELETE FROM invoke_message_bin
            WHERE message_guid = r_invoke_message.message_guid;
      DELETE FROM invoke_message
            WHERE message_guid = r_invoke_message.message_guid;
   END LOOP;
   -- Purge all handled callback messages older than specified date
   --
   FOR r_dlv_message IN c_dlv_message (p_older_than)
   LOOP
      DELETE FROM dlv_message_bin
            WHERE message_guid = r_dlv_message.message_guid;
      DELETE FROM dlv_message
            WHERE message_guid = r_dlv_message.message_guid;
   END LOOP;
END purge_instances;
/

3. Connect to SQLPlus as user orabpel and run the script
For Example:

1
2
3
4
5
6
7
8
9
Declare
    P_OLDER_THAN Timestamp;
Begin
    P_OLDER_THAN := '01/SEP/09 09:05:00 PM';
    PURGE_INSTANCES(P_OLDER_THAN => P_OLDER_THAN);
End;

No comments:

Post a Comment