In 11g we are using the following classes to clear the cache. This class is called from OSB proxy.
CacheProviderManager
CacheProvider
Cache
Here is the piece of code that we have: '
11g:
=============
public static void clearCache(Object cacheName, Object fullServiceName,
Object operation, Object token) {
try {
System.out.println("cacheName :" + cacheName+ ",fullServiceName : " + fullServiceName + ",operation : "+ operation + ", token:" + token);
CacheProviderManager cacheProviderManager = CacheProviderManager.get();
CacheProvider cacheProvider = cacheProviderManager.getCacheProvider();
Cache cache = cacheProvider.getCache(String.valueOf(cacheName));
if (cache != null) {
System.out.println("tostring() : " + cache.toString());
cache.put("arg1", "arg2", "arg3");
System.out.println("get() : " + cache.get("arg1"));
}
cache.clear();
} catch (CacheNotFoundException cnfe) {
cnfe.printStackTrace();
} catch (CacheProviderNotInitializedException cpnie) {
// TODO: Add catch code
cpnie.printStackTrace();
} catch (Exception ex) {
// TODO: Add catch code
ex.printStackTrace();
}
}
Output:
cacheName :/osb/service/ResultCache,fullServiceName : LogES/BusinessServices/LoadDVM,operation : ResetLogCache, token:
tostring() : SafeNamedCache: ViewMap{Name=/osb/service/ResultCache, ClassLoader=weblogic.utils.classloaders.GenericClassLoader@15545d72 finder: weblogic.utils.classloaders.CodeGenClassFinder@400fc3db annotation: ALSB Coherence Cache Provider@, ServiceName=ORA-OSB-deployments}
=============
Now in 12C I replaced the above code with below code:
=============
public static void clearCache(Object cacheName, Object fullServiceName,
Object operation, Object token) {
System.out.println("cacheName : " + cacheName + ", fullServiceName: "+ fullServiceName + ", operation : "+ operation + ", token :" + token);
CacheFactory.ensureCluster();
NamedCache cache = CacheFactory.getCache(String.valueOf(cacheName));
if(cache != null){
System.out.println("size : " + cache.size());
System.out.println("tostring() : " + cache.toString());
for (Iterator iter = cache.keySet().iterator(); iter.hasNext(); )
{
String sKey = (String)iter.next();
System.out.println("Key>> " + sKey + ", value>>" + cache.get(sKey));
}
}
cache.clear();
} //clearCache()
Output from 12C:
cacheName : /osb/service/ResultCache, fullServiceName: LogES/BusinessServices/LoadDVM, operation : ResetLogCache, token :
size : 0
tostring() : SafeNamedCache: ViewMap{Name=/osb/service/ResultCache, ClassLoader=com.bea.wli.sb.resources.archive.classloader.HookedJarClassLoader@12297a5c finder: weblogic.utils.classloaders.CodeGenClassFinder@7bb9e8aa annotation: , ServiceName=DistributedCache}
=============
Above 12C code is not working and cache is not getting cleared. Can you please suggest what changes do we need to make to clear OSB cache in 12C when needed?