http://www.oracle.com/technology/architect/enterprise_solution_cookbook/data_tier_caching_for_soa.html
makes a good reading just to get an idea of how to make a CacheService invoking Coherence. The service can be exposed with a LOCAL transport protocol to avoid marshalling/unmarshalling.
In a nutshell it says: you can cache either Service State (e.g. for a BPM the serialized state of a Process Instance) or Service Result (the result of a DB query).
Cache-aside means: 1) readFromCache 2) miss 3) retrieveFromDB 4) storeInCache
next time you read the same key, you have a hit.
This is very illuminating:
Oracle Coherence offers a Java API; a native service call from BPEL to Coherence was a preference over a standard web service interface. The performance overhead of invoking web service operations is several orders of magnitude larger than that of invoking native Java classes. That's because marshaling and un-marshaling XML, processing SOAP envelopes, etc. are expensive operations.
Note the use of
thread.setContextClassLoader(com.tangosol.net.NamedCache.class.getClassLoader());
to avoid creating a different cache per each classloader in the application! Well done!
(don't forget to set the classloader again to its previous value!)
8 comments:
I have the Result cache enabled in OSB, but am not able to get the keys associated with that from the Cache. It may be related to the Classloader. Coherence jars are loaded as a part of weblogic startup. How can I get access to that classloader and the cache and read the Cache key that is used for Result caching?
Anil, I have seen your post (I guess it's yours) on http://forums.oracle.com/forums/thread.jspa?threadID=2199859&tstart=75
In reality OSB uses a ALSB Coherence Cache provider ( see http://www.javamonamour.org/2010/09/alsb-osb-coherence-cache-provider.html ) which has got its own classloader in its own EAR, so it doesn't use the System Classloader.
Anyway the classloader matters only for Coherence network configuration : if you query the cache from a standalone application, that should not matter as long as you configure it the same as the OSB cache.
If you query the cache from an application running in WebLogic but outside OSB, then you must startup your own Coherence Cluster and configure it the same as OSB cluster... not sure if this would raise conflicts though.... I am not so good at Coherence :o(
Pierluigi - Yes that was my posting on the OTN forum.
I am writing a helper OSB service which can take in the "Cache key" and clear the cache for that key. My other OSB service has result caching enabled. When I use use the regular class loader or just the CacheFactory and get the cache to list the keys persisted in it, it does not show any keys set by OSB. So was the reason I was thinking and looking for a different class loader.
Thanks for the other link. If CacheProviderManager can give me the singleton access to cache it may help probably?
if I find the time I will try to implement this functionality this weekend... can't promise anything anyway :o)
Anil,
Do you got the corret method to get or remove a entry from result cache?
I'm trying to do this, but, so far, all that i got was list and clear a content of cache.
bgbauer - I got side tracked with other priorities. Is it possible for you to share what you did to get the list and clear the content?
Thanks,
Anil
HI,
IS there any way to know the key format of resultcache.
Post a Comment