I have a Java EE web application. Now when a particular request comes (say /xyz url patter) I want to do complex procesing as follows
Each of the following 3 steps are very complex and takes time.
- Get data from one table from DB.Table has huge data and querying takes time.
- Make a web service call to some other webserive A and get its data.
- Make another web service call to some otheer webserice B and get its data .
- Do some processing by using output of 1, 2, 3
1, 2, and 3 are independent of each other so can be called in parallel.
Now the questions are:
- Can I do operations 1, 2, and 3 in three separate threads?
- Is it advisable to create 3 threads for each request?
- Should I use thread pooling?
To address your first question I go through the 4 steps:
Second question
That depends on your data and especially how fast the web services will answer, you should try it out.
Third question Definitively, that’s what they are for. This will also help you to structure your application.