47955

Can we make parallel Service calls using Spring framework

Question:

I have a website with a home page and a search text and button and 5-6 tabs. Based on the search text, there would be independent service calls (API calls to backend) for the tabs. Each tab would have different data. After clicking on search , I am planning to fetch data for one tab and load it in the UI and let the data for other tabs be loaded in the background.

I am planning to use Spring MVC for this task, but I am not sure if spring supports this kind of parallel service calls.

Are there any other frameworks that can do this?

Any pointers would be helpful.

Answer1:

Spring MVC can do this. Because it can handle parallel Requests (It will not take care that they come from the same client).

The "problem" is to have the client to send this parallel requests (one for each tab).

Answer2:

<blockquote>

independent service calls (API calls to backend)

</blockquote>

I guess, you are talking about Ajax requests (HTTP).

All Java EE web framework (and of course SpringFramework MVC) is based on <a href="http://docs.oracle.com/javaee/6/api/javax/servlet/http/HttpServlet.html" rel="nofollow">HttpServlet</a> usage. You may also read <a href="https://www.jcp.org/en/jsr/detail?id=315" rel="nofollow">JSR-315 specification</a>.

What is important, that every servlet request is running in separate thread. Thread creation is carried out by servlet container (tomcat, GlassFish, Jetty, etc), so you are not required to do it manually.

So the answer definitely is yes.

Concerning other frameworks, please look to <a href="https://en.wikipedia.org/wiki/Comparison_of_web_application_frameworks#Java" rel="nofollow">the list in wiki</a>.

UPD. About client. Ajax requests are asynchronous by definition, so it's easy to implement parallel requests.

Small and quick example on how to make parallel calls on client (Jquery):

<script type="text/javascript"> $( document ).ready(function() { $("#searchButton").click(function(){ var pattern = $("#searchText").val(); var processingMap = [ {tabid:"tab1", url:"./first-api-call"}, {tabid:"tab2", url:"./second-api-call"}, {tabid:"tab3", url:"./third-api-call"}, {tabid:"tab4", url:"./fourth-api-call"}, {tabid:"tab5", url:"./fifth-api-call"} ]; $(processingMap).each(function(index, element){ $.ajax(element.url,{ 'type':'get', 'data':{'pattern':pattern}, 'dataType':'text', 'success':function(data, textStatus, jqXHR){ setTabContent(element.tabid,data); } }); }); }); function setTabContent(tabid, content){ $('#'+tabid).text(content); } }); </script> <input type="text" value="" id="searchText"> <input type="button" value="Search" id="searchButton"> <div id="tab1">tab1</div> <div id="tab2">tab2</div> <div id="tab3">tab3</div> <div id="tab4">tab4</div> <div id="tab5">tab5</div>

Recommend

  • eC (Ecere) how to not worry about private data fields of a class
  • including Python.h in C++ file CDT
  • Generating random numbers directly inside a .htaccess file
  • Tools for understanding HTML layout
  • Google OAuth: can't get refresh token with authorization code
  • File extension of zlib zipped html page?
  • Where these are stored?
  • Symfony 2 error page response
  • C#: Import/Export Settings into/from a File
  • Which open source license has no forking [closed]
  • netsh acl setting (need alternative method - registry settings?)
  • how to set variables in a php include file?
  • CSS bleed-through with cfinput type=“datefield”
  • how do i write assembly code from c#?
  • IE11 throwing “SCRIPT1014: invalid character” where all other browsers work
  • Adjust width of select element according to selected option's width
  • Alternative to overridePendingTransition() - Android
  • x64 applications using gdi+: what are the consequences on performance?
  • How to define and use opencv mat of user type
  • Record samples being played with OpenAL
  • Django rest serializer Breaks when data exists
  • How to rebase a series of branches?
  • Recording logins for password protected directories
  • C# - Is there a limit to the size of an httpWebRequest stream?
  • Azure Cloud Service Web Role web pages do not load
  • Updating server-side rendering client-side
  • Cross-Platform Protobuf Serialization
  • what is the difference between the asp.net mvc application and asp.net web application
  • How to make Safari send if-modified-since header?
  • Web-crawler for facebook in python
  • Warning: Can't call setState (or forceUpdate) on an unmounted component
  • How to pass list parameters for each object using Spring MVC?
  • How to format a variable of double type
  • bootstrap to use multiple ng-app
  • How to get icons for entities from eclipse?
  • coudnt use logback because of log4j
  • Exception on Android 4.0 `android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode)`
  • Turn off referential integrity in Derby? is it possible?
  • sending mail using smtp is too slow
  • JaxB to read class hierarchy