Can any one tell me how to prioritize the requests in service method?
Assuming that there are thousands of requests coming to the servlet at the same time, how to prioritize which request to be considered first?
Like Paul mentions it is indeed a strange requirement.
But then if you *really* need to implement something like that you can probably queue up the requests in a synchronised list, and have an independent thread scan this list and pick up requests to service based upon some 'priority' parameter value.
On the flipside, like you mentioned there may be thousands of requests - I really won't suggest using a data-structure to queue up the requests [you never know when your JVM runs out of memory]. Also, I'm pretty sure that the end user [client] experience won't be that great. Especially so, when the server makes him/her wait for a response for no apparent reason [assuming they aren't aware of the prioritisation of requests scenario]
Joined: Apr 23, 2008
Thank you Anirvan and Paul.
Thanks a lot.
This was asked in one of the interviews. I really didn't know the answer.
While it's an unusual requirement, I don't think it's all that odd. There may be contractual QoS stipulations that offer higher priority for some clients (who would presumably have to pay for the privilege).