Community edition Cache

13
Cache For Community Edition

Transcript of Community edition Cache

Page 1: Community edition Cache

Cache For Community Edition

Page 2: Community edition Cache

We have seen examples on Mule Cache mechanism with Cache Scope. But this time we will see implementing Cache for Mule Community Edition.Mule Community Edition doesn’t have the Cache Scope as Mule Enterprise Edition, so to implement Cache in Community Edition we require Custom Interceptor.

You can already refer https://github.com/ddossot/mule-in-action-2e/blob/master/chapter12/src/main/java/com/prancingdonkey/interceptor/PayloadCacheInterceptor.java which shows implementing Cache in Community Edition by David Dassot.In my demonstration I have modified the code and implemented on the top of it with additional Filter Expression

Page 3: Community edition Cache

How to Cache with Community Edition??

Page 4: Community edition Cache

To use Cache with Mule we have to construct our flow in following way :-

You can see the flow is divided into 2 parts and is connected by VM component. You can see we have used Custom Interceptor to implement Cache in this Community Edition

Page 5: Community edition Cache

Our Mule config will be as follow:-

You can see we are using our Custom interceptor implemented and a spring property filterExpression which will filter the expression we want to implement .

Page 6: Community edition Cache

Our Custom interceptor Java class:-

Page 7: Community edition Cache

In next step we will be running and testing the application. This web service will interact with database retrieve a row from the database and show the row value in the SOAP response.

Page 8: Community edition Cache

Here how we will test the web service :-

You can see that we have used SoapUI to test the web service. Now when we hit the service, you can see in the SOAP request, it takes id as input and then fetches all the data from the database for that id.

Page 9: Community edition Cache

Now, what we will do is manually deleting the entire row from the database. In my case, I have used sql server and deleted the row from the table using a SQL query:-

Page 10: Community edition Cache

With this in place, if we again hit the service, we will get the same response as we got earlier:-

And that means our Cache is working and it’s responding from the Cache and not hitting the actual Database !!! So our Custom interceptor is implementing the Cache !!

Page 11: Community edition Cache

So you can see that we have implemented the Cache for the Community Edition which has the feature of filtering the expression like the Cache scope of Enterprise Edition. So, you can implement your own Cache using Custom Interceptor.

Page 12: Community edition Cache

In my next slide I will bring some other techniques in Mule implementation .Hope you have enjoyed this simpler version. Keep sharing your knowledge and let our Mule community grow

Page 13: Community edition Cache

Thank You