The gateway server is a server component that acts as intermediary between external clients which perform requests for resources, and the resource providers.
The particularity of the gateway server is that the resource providers connect to the gateway using a comet protocol.
The comet procotol functionality is implemented by a gateway client.
This is quite different from a normal proxy server where it is the proxy that connects to the resource providers.
Schematically, this is how the gateway server works:
External Client Gateway Server Gateway Client Resource Provider | | | <-- comet req. 1 --- | | --- ext. req. 1 --> | | | | --- comet res. 1 --> | | | <-- comet req. 2 --- | | | --- ext. req. 1 --> | | | | <-- ext. res. 1 --- | | | <-- ext. res. 1 --- | | <-- ext. res. 1 --- | | --- ext. req. 2 --> | | | --- comet res. 2 --> | . . .
The gateway server is made of two servlets:
External requests are suspended using Jetty continuations until a response for that request arrives from the resource provider, or a {@link #getExternalTimeout() configurable timeout} expires.
Comet requests made by the gateway client also expires after a (different) {@link #getGatewayTimeout() configurable timeout}.
External requests are packed into {@link RHTTPRequest} objects, converted into anopaque byte array and sent as the body of the comet reponse to the gateway {@link RHTTPClient}.
The gateway client uses a notification mechanism to alert listeners interested in external requests that have been forwarded through the gateway. It is up to the listeners to connect to the resource provider however they like.
When the gateway client receives a response from the resource provider, it packs the response into a {@link RHTTPResponse} object, converts it into an opaque byte arrayand sends it as the body of a normal HTTP request to the gateway server.
It is possible to connect more than one gateway client to a gateway server; each gateway client is identified by a unique targetId.
External requests must specify a targetId that allows the gateway server to forward the requests to the specific gateway client; how the targetId is retrieved from an external request is handled by {@link TargetIdRetriever} implementations.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|