Request Execution in WebLogic pub-sub Server
WebLogic provides HTTP Publish Subscriber(pub-sub) server is a mechanism whereby Web clients subscribe to channels and then publish messages to these channels using asynchronous messages over HTTP. It is based on the Bayeux protocol proposed by the cometd project.
Client requests of the sample stock application(SAMPLES_HOME
\server\examples\src\examples\webapp\pubsub\stock)
were traced to understand request execution and thread resource utilization in WebLogic pub-sub server.
Bayeux Publish
Publisher(stand alone Java client) publishes stock data over HTTP protocol every 2 seconds. Following corresponding HTTP log event is written in WebLogic access.log
127.0.0.1 - Publisher [27/May/2010:16:27:54 -0400] "POST /stock/cometd HTTP/1.1" 200 3902
WebLogic PubSub server handles publish request using internal asynchronous servlet com.bea.httppubsub.servlet.ControllerServlet. For a given channel publish event repeats every 2 seconds. Async publish request does not wait for response. It executes request much faster than traditional HTTP request/response and so forth utilizes thread resources more efficiently.
Figure 1 Publish Even Execution Trace In Weblogic. (Please click on image to view larger image)
Bayeux Subscribe
Subscriber (Browser Java Script Client) subscribes pub-sub server channel and exchanges messages over HTTP using long-polling protocol.
Figure 2 Example Subscriber Client. (Please click on image to view larger image)
Long polling, also known as asynchronous polling, is a hybrid of pure server push and client pull. It is based on the Bayeux protocol. As in streaming, a client subscribes to a connection channel on the server by sending a request. The server holds the request and waits for an event to happen. Once the event occurs (or after a predefined timeout), a complete response message is sent to the client. Upon receiving the response, the client immediately sends a new request. The server, then, almost always has an outstanding request that it can use to deliver data in response to a server-side event.
Each long polling Subscriber request is logged as HTTP Post request in WebLogic HTTP Access log.
144.10.131.194 - Subscriber [01/Jun/2010:14:59:31 -0400] "POST /stock/cometd HTTP/1.1" 200 187
Figure 3 Subscribe Request Execution Trace In Weblogic. (Please click on image to view larger image)
Similar to publish request server also handles subscribe event using internal Asynchronous servlet com.bea.httppubsub.servlet.ControllerServlet. Every pending request is notified with published new set of data and writes response back to Bayeux client. Upon receipt of the response data, client immediately issues new request in anticipation next set of data to implement streaming behavior.