Sometimes we need to purge the huge notification queue in ebs workflow, because of mailer services got failed and giving an error while starting or while refreshing/cloning new instance.
As we know that old email notification not needed in cloned instance. In this scenario we have to purge all those workflow notification queue from cloned ebs instance.
Below script will verify the current status in table WF_NOTIFICATIONS that has to be sent when mailer services gets started.
SQL>select notification_id, begin_date, recipient_role, message_type, message_name, status, mail_status from wf_notifications Where Status In ('OPEN', 'CANCELED') And Mail_Status In ('MAIL', 'INVALID') --and begin_date < sysdate-30 --> List only emails older than 30 days ago order by notification_id;
Output:-
NOTIFICATION_ID BEGIN_DATE RECIPIENT_ROLE MESSAGE_TYPE
MESSAGE_NAME STATUS MAIL_STATUS
6273813 4/26/2016 4:01:17 PM SYSADMIN OMERROR OMERROR_MSG
OPEN MAIL
6273814 4/26/2016 4:01:18 PM SYSADMIN OMERROR OMERROR_MSG
OPEN MAIL
6273815 4/26/2016 4:01:18 PM SYSADMIN OMERROR OMERROR_MSG
OPEN MAIL
6273816 4/26/2016 4:01:19 PM SYSADMIN OMERROR OMERROR_MSG
OPEN MAIL
Update the mail_status to sent , if you have not requirement for old workflow email notification. It will not en-queue the messages again.
SQL>update WF_NOTIFICATIONS set mail_status = 'SENT' where mail_status in ('MAIL','INVALID') and Status In ('OPEN', 'CANCELED');
Purge the WF_NOTIFICATION_OUT queue and rebuild it with data currently in the WF_NOTIFICATIONS table.
SQL> @$FND_TOP/patch/115/sql/wfntfqup.sql apps apps applsys
PL/SQL procedure successfully completed.
Elapsed: 00:00:01.01
Commit complete.
Elapsed: 00:00:00.00
**** TEMPORARY TABLES / AQs created ****
PL/SQL procedure successfully completed.
Elapsed: 00:00:01.43
**** Messages backed up ****
Commit complete.
Elapsed: 00:00:00.00
**** wfaqback.sql completed, executing SQLs from wfntfqup
PL/SQL procedure successfully completed.
Elapsed: 00:00:17.37
*** invoking wfaqrenq.sql ******
*** Re-enqueing messages
PL/SQL procedure successfully completed.
Elapsed: 00:00:00.26
Commit complete.
Elapsed: 00:00:00.00
***** Objects related to wf_queue_temp_evt_table and
wf_queue_temp_jms_table are dropped *****
***** Re-enqueue OF Alerts completed *****
Disconnected from Oracle Database 11g Enterprise Edition Release
11.2.0.4.0 - 64 bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options
[applmgr@prdsrv scripts]$
After that need to be start the workflow mailer services.


