Tuesday, March 13, 2012

Coherence set up in OSB

Oracle service bus has a build in functionality for caching the data using coherence.

So a prerequisite for Resulting cache is that you should have coherence set up at your end.

The cache is enabled for Business service only and not for proxy service.

LEts take an example to understand what it exactly does.

LEt suppose you have a business service which is calling a standby database to query data.In real life time scenario you can take it as customer details.

So if same customer calls this service again and again ideally it will call the business service again and again,this process will involve calling the adapter and getting the result ..this process will take time in seconds but we are already aware that it is a passive data and is not going to change so what we can do it that we can store the records of the customer in a cache so that the next time the customer tries to get its data he doesn't have to call the adapter and call the procedure to get the data ,instead he can directly get the data from the cache.


So here there are two important things to notice first is that our business service will be invoked once for a particular customer and then the result will be stored in the cache.

The second thing will be the speed will be much faster accessing the data from cache than calling the procedure to get the data.

So as i mentioned for a particular customer it will store the data.So that customer must have some unique attribute so that the cache can store it against that value.That particular value is the Cache Key.


So as you can see the Cache key will be used to store the value in the Cache.

So now i will go to a real service and show you what exactly will happen in real time scenario.

YOu can go to the health of process and we have two operation there for the proxy service.

Current Aggregation Interval and Since last reset.

We will use the second option to identify how is our process behaving.For that purpose first of all reset the statistics from osb console.
Test the proxy service 10 times which is calling this particular business service and now check the statistics
As you will find that the proxy as well as business service both have been called 10 times in the stats.This is because we have not set the cache.


Now we will again reset the statistics and configure the result cache.

To configure result cache.

Go to the business service.

Go to advance setting and click on Result Caching Supported.

Once set it will ask for the key ...it should be the unique key for the customer.

Lets say it is customer id so your unique will be like this

$body/CustomerUniqueKey

Now save this result and again call this proxy service 10 times.

This time if you will go to the statistics you will find that proxy service has been called 10 times but the business service is called only once.

Also note the timing difference the aggregated time interval is much less in this case because of result caching.

No comments: