The Oracle Commerce Platform includes a standard HTTP request-handling mechanism for implementing HTML-based interfaces to applications. Your applications might want to create additional TCP servers to handle other types of requests from outside sources. These servers all run within the same process.
The class atg.server.tcp.RequestServer
provides a mechanism for building TCP servers. When the RequestServer
starts, it creates a server socket that waits on a specific port. It also creates a number of atg.server.tcp.RequestServerHandler
objects that run in their own separate threads. The RequestServer
then waits for incoming connections, and each incoming connection is passed to a free RequestServerHandler
to be handled. If no RequestServerHandler
objects are free, the RequestServer
waits until one is free. When a RequestServerHandler
is done handling a request, the handler is returned to the pool of handlers waiting for requests until it is asked to handle another request. A RequestServer
reuses RequestServerHandler
objects between requests—it does not create and destroy RequestServerHandler
objects on each request. This enables high throughput for request-based services that require high performance.
To use the RequestServer
class, you must extend the RequestServerHandler
and implement the handleRequest
method to actually handle the request. You must also extend RequestServer
and implement the createHandler
method to create instances of your RequestServerHandler
subclass. When you configure a RequestServer
instance, you specify the port and number of handlers that are created.