May 1st, 2012, 09:31 AM
I'm working on an application that offers a REST API. The REST API makes service calls to Hibernate/MySQL. We've come up with a design such that our web application handles all client requests by issuing requests to our REST API under the covers. This allows us to abstract away any potential database changes and what not. Basically, this looks as follows:
Browser --> Controller -> REST call --> Controller --> Database
Notice the 2 controllers. This makes for a nice architecture, but we're having an issue. The first controller is basically making another HTTP request to the REST API. This results in timeouts in the initial client request in the case of costly database queries and such.
I have a couple questions.
1) Is there a way to trick Spring (from within the web app) to not make an actual HTTP request? For example, can the RestTemplate be configured to just invoke the latter controller without a real request? This would allow us to avoid timeouts and speed up the app.
2) What are your thoughts on this general design? Any suggestions or comments for improving performance and avoiding timeouts?