Oracle BI EE 10.1.3.3/2 – Scheduling Cache Purging – Phase 2 – Using Java and Delivers

If you had seen my previous blog entry here, i would have shown you a procedure to purge the cache on a periodic basis using Java Script. I was asked today about the possibility of doing the same using Java. So, lets look today how to go about scheduling cache purges using Java and Delivers.
1.   The 1st step to achieve this is to create a SQL.txt file containing the actual ODBC call.
{call SAPurgeAllCache()};
      
In my case, i have created this in D:\ drive.
2.   Now, create a batch file which would make the following call to NQCmd.exe. You can store the batch file anywhere. The following would be the contents of the batch file.
D:\Oracle\OracleBI\server\Bin\nqcmd.exe -d AnalyticsWeb -u Administrator -p Administrator -s D:\SQL.txt -o D:\Output.txt
3.   Open JDeveloper and compile the following java program.
package bieesoap;
import com.siebel.analytics.scheduler.javahostrpccalls.SchedulerJavaExtension;
import com.siebel.analytics.scheduler.javahostrpccalls.SchedulerJobException;
import com.siebel.analytics.scheduler.javahostrpccalls.SchedulerJobInfo;
public class CachePurgeRun implements SchedulerJavaExtension {
public CachePurgeRun() {
}
public void run(SchedulerJobInfo jobInfo) throws SchedulerJobException
{
try
{
Process p = null;
//String[] cmdAry = {nqCmd,” -d “, dsn, ” -u “, user, ” -p “, pswd, ” -s “, tempInFileName, ” -o “, tempOutFileName};
String[] cmdAry = {“D:\\CachePurge.bat”};
p = Runtime.getRuntime().exec(cmdAry);
}
catch(Exception ex)
{
throw new SchedulerJobException(1, 1, ex.getMessage());
}
}
public void cancel() {
}
}
As you see, what this above code does is, it makes a call to the NQCMD.exe file and passes the SQL.txt file as its argument. Once this is executed the output would be stored in the output.txt file.
4.   Now, bundle the above java code into a jar file (for details on how to do this check my blog entry here
5.   Once this is done, just go to delivers and call this java class from the Advanced tab. You can schedule this periodically.
      
6.   Just keep checking the output.txt to know whether the cache purge has completed successfully.