How to purge BPEL process instances manually?
Friday, January 29, 2010
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
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:
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;