Service Result Caching is one of the options that you can use when you want to improve Oracle Service Bus performance. Service Result caching is used when we have business service which connects to external service which returns somewhat static response. So by using Service Result Caching we don’t hit external service for same request instead it will take the response from cache which improve the OSB performance.
We can also set the Time to live for cache. Once that time expires business service will again hit the external service for response.
In this post, I will show you one use case of service response caching.
For this post, I have created a SOA composite which we use a external service. In the SOA composite, I put a wait activity of 30 seconds. So ideally first time when we invoke business service then it should return the response after 30 seconds only and when we call it next time with same request then it should not take more than 1-5 seconds as it get the response from cache.
First create a SOA composite, add a Synchronous BPEL to it. Simply assign the request to response and put 30 seconds wait activity.
Now create a new project is OSB. Import above created SOA Composite WSDL & Schema file to this OSB project.
Now create a Business service which invokes external service (SOA Composite). Name your business service and choose SOA Composite as service type.
To configure the caching for this business service, click on “Result caching” check box and enable the result caching.
You also need to specify “Cache Token Expression” which will be your request message key value.
Set Expiration Time for caching. Once this time expires , business service again get the data from external service instead of cache.
Now create a proxy service which invokes above created business service.
Test your proxy service, since this is the first time so business service will invoke the external service and get the response. We have added 30 second wait activity in external service so we should get response after 30 seconds only.
Now test you proxy with same request. Now you should immediately get the response as business service take the response from cache.
Hello mr. Garg,ReplyDelete
I'm looking to alter the Expiration time in a customization file. Would you happen to know how to do this? It doesn't show up in the generated ALSBCustomizationFile.xml
I don't thing expiration times comes in customisation file, you need to manually edit it if needed.Delete