Tuesday, March 11, 2014

OSB Result Caching

OSB result caching is a OSB feature to cache business service response for a given request.OSB uses Coherence to support caching.As we all know, if we enable caching g in right way then it increases application performance
Now let's talk about OSB with Coherence framework


Given caching is enabled,when request comes to OSB business service, it first checks in cache and  returns result to caller if it finds otherwise it calls back end external service,returns the result to caller and loads the result into cache for next time caller.
Cache also expires based on configured parameter, if cache is expired,the next service call will be routed to back end service and cache will be updated
Here we get the performance by avoiding calls to  back end service


Cache is implemented like Java Map(key,value) pairs, where key is combination of request or part of request identified by cache token ,business service full path and operation being invoked on business service  and value is returned response

So each cached result is  uniquely identified by a cache key

cache-token metadata element value can be expressed on business service configuration or can be set on one of request metadata variables from proxy service message flow
cache-ttl(expiration time,ttl stands for TimeToLive) element value can be expressed on business service configuration or can be set on one of request metadata variables from proxy service message flow
 
Caching needs to be enabled on business service as mentioned in below picture


When expiration time on BS is set to default as shown above, then expiration time is taken from OSB coherence config file- //config/osb/coherence/osb-coherence-cache-config.xml
By default it is set to 5 minutes, you can change this value to required hours(for example, 24h) or days  and restart osb server to reflect the change

TTL and cache token values in the request from proxy service will override the business service configuration parameters.


Note:
Make sure we also enable result caching at
Go to the SBConsole > Operations > Global Settings and enable Result Caching