Distribute messages across multiple sinks, choosing which sink to send
any particular message to randomly, but weighing in the relative sink
priority. Exactly how that weighing is done is implementation-dependent. In
diagram form:
+-------------+
|Alternator |
addSink() | +---------+|
------> |/-|Sink ||
|| +---------+|
|| +---------+|
put() / offer() --->-|Sink ||
|| +---------+|
|| +---------+|
|\-|Sink ||
| +---------+|
+-------------+
Note that the Alternator is very similar to the
Multicaster Multicaster : where the multicaster sends a received message to
all connected sinks, the Alternator sends it to only one sink.
Also note that the Alternator is also very similar to the
org.jicarilla.plumbing.Screener screener : where the alternator decides which connected sink
should receive the message randomly, the screener does so based on a
user-provided configuration.
author: Leo Simons version: $Id: Alternator.java,v 1.1 2004/03/22 21:20:13 lsimons Exp $ |