5.6. A Consumer Channel

We're now going to explore a variant of the channel, in which processes consume messages as they retrieve them. We call this kind of channel a consumer channel. One common use of a consumer channel is to provide a task queue. With a task queue, writers add tasks (requests for services) into the channel and worker processes remove and process the tasks (computing them or providing some other service). Since each task only needs to be processed once, a consumer channel provides a natural way to store the requests. At the same time, it allows requests to be processed in a first-come, first-served manner.

5.6.1. Implementing a Pager Service

Rather than implement a task queue, we are going to explore consumer channels with ...

Get JavaSpaces™ Principles, Patterns, and Practice now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.