You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Praveen Balaji <pb...@tibco.com> on 2007/04/25 11:51:25 UTC

Tomcat - CometProcessor question

Hi all,
Not sure if the subject is appropriate. Here's a description of what I
need to achieve:

I have a servlet that can block on a request for a long duration. This
essentially means the Tomcat processor thread that is serving the HTTP
request is blocked and unable to process more incoming requests.

>From a broader sense, what I need to achieve is to get hold of the
client socket I/O streams and let the Tomcat processor thread free. I
want to process the request OUTSIDE the lifecycle of the service method.
This is so I can achieve better response time with less processor
threads.

I understand that the Servlet Specification no longer mandates that the
request be serviced in the service method. I also understand that
Tomcat6 leverages java's NIO support to provide these non-blocking
semantics to servlets that implement CometProcessor. However, my
observation is that this is particularly useful for AJAX (and similar)
client applications that use a keep alive connection to provide
responsive UI. My primary requirement is that:

1.	I have control of reading the request. I do not want to wait on
comet events to read the request payload.
2.	I should be able to respond at a later point of time. So I need
a handle to the socket output stream.

Is the NIO Connector and CometProcessor the right solution for my
problem? If yes, how do I achieve the above requirements? If not, does
Tomcat provide me any alternatives?


Any help will be greatly appreciated and willingly devoured.

Thanks,
Praveen

RE: Tomcat - CometProcessor question

Posted by Praveen Balaji <pb...@tibco.com>.
This was useful. Thanks. I should have tried this before posting the
question!

I also went through the bug you filed for synchronization. Again,
useful.

Thanks,
Praveen

-----Original Message-----
From: Reich, Matthias [mailto:matthias.reich@siemens.com] 
Sent: Wednesday, April 25, 2007 6:31 PM
To: Tomcat Users List
Subject: RE: Tomcat - CometProcessor question

Hi,

I am working on a similar scenario and currently elaborate on the Comet
interfaces.

1. With the BEGIN event you get a fully parsed request object, i.e. you
don't need to wait for READ events to start processing the request.

2. You can keep a reference to the request and response object so that
you will be able to send the Response asynchronously.

Thus, I think Comet is the right offering for such a scenario.

However, I already learned the lesson, that you need to carefully
sychronize access especially to the response object
between the thread that runs the servlet's event method and the thread
that provides the result.
In my tests, I am still struggeling with problems like e.g. memory
leaks, so I am not yet in the situation of having a stable running
solution.


Regards,
Matthias Reich

-----Original Message-----
From: Praveen Balaji [mailto:pbalaji@tibco.com] 
Sent: Wednesday, April 25, 2007 11:51 AM
To: users@tomcat.apache.org
Subject: Tomcat - CometProcessor question

Hi all,
Not sure if the subject is appropriate. Here's a description of what I
need to achieve:

I have a servlet that can block on a request for a long duration. This
essentially means the Tomcat processor thread that is serving the HTTP
request is blocked and unable to process more incoming requests.

>From a broader sense, what I need to achieve is to get hold of the
client socket I/O streams and let the Tomcat processor thread free. I
want to process the request OUTSIDE the lifecycle of the service method.
This is so I can achieve better response time with less processor
threads.

I understand that the Servlet Specification no longer mandates that the
request be serviced in the service method. I also understand that
Tomcat6 leverages java's NIO support to provide these non-blocking
semantics to servlets that implement CometProcessor. However, my
observation is that this is particularly useful for AJAX (and similar)
client applications that use a keep alive connection to provide
responsive UI. My primary requirement is that:

1.	I have control of reading the request. I do not want to wait on
comet events to read the request payload.
2.	I should be able to respond at a later point of time. So I need
a handle to the socket output stream.

Is the NIO Connector and CometProcessor the right solution for my
problem? If yes, how do I achieve the above requirements? If not, does
Tomcat provide me any alternatives?


Any help will be greatly appreciated and willingly devoured.

Thanks,
Praveen

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: Tomcat - CometProcessor question

Posted by "Reich, Matthias" <ma...@siemens.com>.
Hi,

I am working on a similar scenario and currently elaborate on the Comet
interfaces.

1. With the BEGIN event you get a fully parsed request object, i.e. you
don't need to wait for READ events to start processing the request.

2. You can keep a reference to the request and response object so that
you will be able to send the Response asynchronously.

Thus, I think Comet is the right offering for such a scenario.

However, I already learned the lesson, that you need to carefully
sychronize access especially to the response object
between the thread that runs the servlet's event method and the thread
that provides the result.
In my tests, I am still struggeling with problems like e.g. memory
leaks, so I am not yet in the situation of having a stable running
solution.


Regards,
Matthias Reich

-----Original Message-----
From: Praveen Balaji [mailto:pbalaji@tibco.com] 
Sent: Wednesday, April 25, 2007 11:51 AM
To: users@tomcat.apache.org
Subject: Tomcat - CometProcessor question

Hi all,
Not sure if the subject is appropriate. Here's a description of what I
need to achieve:

I have a servlet that can block on a request for a long duration. This
essentially means the Tomcat processor thread that is serving the HTTP
request is blocked and unable to process more incoming requests.

>From a broader sense, what I need to achieve is to get hold of the
client socket I/O streams and let the Tomcat processor thread free. I
want to process the request OUTSIDE the lifecycle of the service method.
This is so I can achieve better response time with less processor
threads.

I understand that the Servlet Specification no longer mandates that the
request be serviced in the service method. I also understand that
Tomcat6 leverages java's NIO support to provide these non-blocking
semantics to servlets that implement CometProcessor. However, my
observation is that this is particularly useful for AJAX (and similar)
client applications that use a keep alive connection to provide
responsive UI. My primary requirement is that:

1.	I have control of reading the request. I do not want to wait on
comet events to read the request payload.
2.	I should be able to respond at a later point of time. So I need
a handle to the socket output stream.

Is the NIO Connector and CometProcessor the right solution for my
problem? If yes, how do I achieve the above requirements? If not, does
Tomcat provide me any alternatives?


Any help will be greatly appreciated and willingly devoured.

Thanks,
Praveen

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org