• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

Configure Tomcat to run both Comet Pushlets and regular servlet simultaneously

 
Greenhorn
Posts: 6
jQuery Netbeans IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Guys,

I have written a conventional servlet application.
Now I want to add a new servlet that supports COMET long polling.

In researching this I found that I would have to use the following connector to support COMET pushlets.

<Connector connectionTimeout="20000" port="8080" protocol="org.apache.
coyote.http11.Http11NioProtocol" redirectPort="8443"/>

I want however that single TOMCAT installation can support both the conventional servlet requests as well as the long polling requests.

Can somebody tell me how to configure Tomcat so that it can handle both types of requests.
 
Bartender
Posts: 1210
25
Android Python PHP C++ Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Comet support and events are activated for a servlet only if it implements org.apache.catalina.CometProcessor. Otherwise, its normal servlet doGet/doPost service methods are invoked.
 
Frank Hilhorst
Greenhorn
Posts: 6
jQuery Netbeans IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

This sounds like it doesn't matter which connector you use.
I read that Comet requires non blocking sockets (in other words use the NIO connector).
Which connector should I use?
 
Karthik Shiraly
Bartender
Posts: 1210
25
Android Python PHP C++ Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Frank Hilhorst wrote:
This sounds like it doesn't matter which connector you use.
I read that Comet requires non blocking sockets (in other words use the NIO connector).
Which connector should I use?



You have to use HTTP NIO connector (edit: or APR connector, but I haven't tried that out) , because the blocking nature of regular HTTP connector makes Comet functionality impossible.

NIO connector - like all asynchronous designs - is capable of both asynchronous and synchronous operation. Generally, it's impossible to make a synchronous flow asynchronous, but it's possible to make any asynchronous flow behave synchronously. If you open tomcat source code, you'll find StandardValve and HttpNioConnector full of code like "if (comet) {...} else {...}". So, NIO connector is a superset of blocking connector.

If servlet doesn't implement CometProcessor, it's treated as a regular servlet and the flow is like old synchronous servlet.
If it does implement, it's treated as an asynchronous comet pushlet.

Tomcat Comet Reference
 
Frank Hilhorst
Greenhorn
Posts: 6
jQuery Netbeans IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Thanks Kathik,

This information is exactly what I was looking for.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!