Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Applied Java™ Patterns - Stephen Stelting, Olav Maassen.pdf
Скачиваний:
202
Добавлен:
24.05.2014
Размер:
2.84 Mб
Скачать

Server push is most appropriate for cases where:

Real-time (or near real-time) updates are required by the client

Data changes on an infrequent, unpredictable basis

Server push is frequently used on the Web for interactive applications such as gaming or chat rooms. Business applications sometimes use it to provide updates for collaborative resources, such as documents that are managed by groupware.

Mailing lists offer an excellent example of server push. After requesting to be put on a company’s mailing list, the client (customer) receives a series of messages from the server (company) notifying her or him about a variety of products that are (or presumably will be) for sale. The client can then respond to these notifications by buying a year’s subscription to Horse and Hound magazine, or frantically trying to find the Web site that lets you get off mailing lists.

Implementation

Successive Update has different client and server requirements based on the strategy followed. For client pull solutions, the client must have some way to establish a polling interval for the server. Frequently, this is managed by a thread in the client to periodically query the server and provide the client with results. The server has no special requirements in this implementation. Server push requires the server to keep track of the interested clients in some way. The server must send a notification each time events occur on the server that warrant a client update.

Benefits and Drawbacks

The benefits and drawbacks of the Successive Update pattern vary depending on whether the implementation uses a client pull or server push solution.

Depending on the rate at which the data changes, either strategy may put less load on the server. If the rate of change is high, client pull puts less load on the server; if the changes are less frequent, server push puts a lower demand on the server. Server push provides the most responsive update of information and might be a more efficient communication overall.

Disadvantages for client pull include the lack of timely updates of information and the risk of redundant data transfer. The client always asks for an update even when nothing has changed on the server, so the same data will be resent. Both drawbacks stem from the fact that a client cannot truly determine when there has been a change on the server. For server push, drawbacks may include increased server workload, or possible irrelevant traffic for

169