Erik Pischel wrote:
> Hi,
>
> for academic purpose I want to introduce a real-time algorithm
> in a web server. Since I'm quite familiar with java, i thought
> of tomcat... B/W a wonderfull 'product', thanks for all the dev.
> efforts!
>
> what I want to do: when requests arrive and are queued, order
> this queue due to some sort order. I would probably want to read a
> parameter from that request (aka HttpRequest.getParameter)
> to determine the sort order.
>
> now my following questions: is there something like a queue for
> requests waiting to be processed?
No, there is not. There is a thread that accepts connections from the server
socket, and immediately hands them off to request processing threads. The
number of request processing threads determines the number of simultaneous
requests you can handle -- if you get more than that, they will stack up in the
TCP/IP layer (up to the backlog you have configured on the server socket), and
any further requestors will start getting connection errors.
> if not, would it be likely to
> implement that without violating the whole design of tomcat? Are
> parameters available at that point or are they "extracted" later?
>
It's not just a Tomcat issue (although there is a significant one -- see
below). You also have to deal with the servlet spec, where access to the
request and response objects outside of the request processing thread's call to
the service() method will result in undefined behavior.
For Tomcat in particular, and for any other container that recycles request and
response objects, you're going to have a big problem trying to queue up requests
and responses. Tomcat recycles the actual object instances on subsequent
requests -- so that, as soon as it processes another request and reuses the same
request instance, the previous contents of that request instance are lost.
>
> If I happen to implement that feature, of course I'll
> let you know about the outcoming and share to source!
>
It is certainly feasible to implement yourself a background processing queue,
with the incoming requests creating new entries in the queue and then using one
or more processing threads to remove them. All you need to do is make sure you
copy the relevant information out of the HttpServletRequest objects that you
receive and into the objects (of your own design) that you add to the queue.
NOTE: If your users are going to wait for the responses anyway, there would be
no "value add" in creating a processing queue -- the multithreaded nature of
Tomcat already lets you deal with multiple simultaneous requests, and configure
how many you are willing to support.
>
> bye,
> erik
>
Craig McClanahan
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]