This week's book giveaway is in the OCMJEA forum. We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line! See this thread for details.
Is there any way to control the order of processing of individual requests in Tomcat? Say that 100 requests come in within a 1 second period and the handling of each request takes 3 to 4 seconds. Is there any way to ensure that each of those requests is completed in the order it is received?
Seems to me you could write your own mechanism - how about putting each arriving request Thread in a queue in a long sleep state. A separate working Thread could remove a request Thread from the queue and interrupt it to resume processing.
HTTP servers are designed to handle all requests at an equal priority. In theory, that means first-in, first-out, but in the case of HTTP servers like Tomcat and Apache, the requests are dispatched to individual handler threads running asynchronously, so the concept of order of arrival doesn't even begin to apply until all the threads in the server are busy and queueing needs to be done.
This isn't just a Tomcat issue, and it isn't just a Java issue. Like the forbidding of unsolicited responses, it's part of the basic architectural definition of how HTTP works as defined in the various RFCs that make up the standards.
If you want some sort of ordering or prioritizing, you'd have to look elsewhere. To make a FIFO out of an HTTP server, you'd actually have to downgrade its functionality (use only one thread). If you're looking at prioritization of traffic, you'd generally have to play games with your routers and switches.
Alternatively, you could use a non-HTTP protocol that supports such refinements, such as a messaging service. However, non-HTTP means that you'll need a custom app to submit them, since web browsers deal in HTTP, and like I said, HTTP doesn't support that.
Customer surveys are for companies who didn't pay proper attention to begin with.