Spring Integration - Cache requests for inbound/outbound gateway
by GarciaPL on Sunday, 8 January 2017
Do you use inbound or outbound http gateway in Spring Integration and you was thinking about caching some requests ? There is a solution for that! It's can be achieved with <request-handler-advice-chain> and Spring Cache Advice.
<int-http:outbound-gateway> <int-http:request-handler-advice-chain> <cache:advice> <cache:caching cache="cacheKey"> <cache:cacheable method="handle*Message" key="#a0.payload.id"/> </cache:caching> </cache:advice> </int-http:request-handler-advice-chain> </int-http:outbound-gateway>
You might see above that handle*Message will be considered by Spring Cache Advice to invoke cache functionality. To be more specific we are thinking about handleRequestMessage method and it's parameters defined as a part of HttpRequestExecutingMessageHandler which will be considered as a key - id in our case. Moreover you need to define explicitly cacheManager bean and define key for cache entry (cacheKey in our case) using for instance EhCache.
References : [1] Spring Integration - Cache for inbound/outbound gateway
Some of you might be interested in presentation which I made recently for internal training purpose. Topic is "Packer by HashiCorp".
Some of you might know this unofficial Stack Careers Android app which allows you search job in IT sector. There is a link => Stack Careers on Google Play. I have been using it for a while, but some time ago it stopped working. Only what I got was : 'No Results'. So, I downloaded repository and found out that feed API of Stack Careers has been changed. I mean that application got HTTP 301 status which means Moved Permanently and no redirect has been performed using standard HttpConnection component of Android stack. More info about what I did you might find below and under pull request link.
In fact that I have been using you app occasionally, I found someday that it does not work now. I managed to figure out that guys from Stackoverflow changed feed API and moreover you app was not able to follow up redirect (HTTP 301 Moved Permanently).
So, according to this pull request what I did and what I did not :
- feed API has not been changed
- added OkHttp library within required by it another library called Okio
- replaced HttpURLConnection with client from OkHttp
- added required rules for proguard to cover up OkHttp
I also would like to mention that feed API for Stack careers has been changed from
http://careers.stackoverflow.com/jobs/feed => https://stackoverflow.com/jobs/feed
PS. I hope that author of Stack Career will accept my fix for that problem and eventually some day we might be able to download new app from Google Play.
Reference :
[1] Stack Careers - pull request
Some of you might be interested in presentation which I made recently for internal training purpose. Topic is "Consul and Consul Pusher".
Some of you might thinking how to create sequence for table which contains some records. You might always export all records from database, then eventually create sequence and after all import those records once again into database. Nevertheless there is a solution how to create this sequence using PL/SQL.
DECLARE seq_value_holder NUMBER; BEGIN -- create a sequence for YOUR_TABLE SELECT NVL(MAX(id), 0) + 1 INTO seq_value_holder FROM YOUR_TABLE; EXECUTE immediate 'create sequence SEQ_YOUR_TABLE start with ' || seq_value_holder || ' increment by 1'; END;
A few days ago, I got an email with inquiry if I would like to participate in recruitment process to Google. I thought why not. It is always good to gain some experience around that. After a phone interview which was not successful for me, but I am not sad about that fact at all, I thought that I might give you some insight what areas you should refresh or just learn quickly. Of course your questions will be correlated with those areas which you picked up before phone interview, but I assume that some of them might be similar with those which I chose.
- Operating systems - monitors, semaphores, mutexes, linux, unix, processes, inode
- Algorithm Complexity - big O notation for different algorithms. Provide some complexity for sorting algorithms. Pick up those data structures which have following complexity for instance O(n log (n))
- Mathematics - calculate something very quickly in mind for instance 2 to the power of 32
- Trees - big O notation for different operation performed on trees like AVL, Binary trees
- Java - question related to programming language which you chose
