The
MessageRouter
class facilitates intra-process message routing. It provides
application classes with convenient access to the message channels via the
PrintWriter
class. The
MessageRouter
class, by default, defines 2
standard message channels - for standard output and standard error messages. Applications can
publish their standard output and standard error messages using the
outWriter()
and
errWriter()
methods correspondingly.
The
MessageRouter
class distributes the messages to a number of message channel listeners, added by applications.
Standard message channel listeners should implement the
MessageRouter.StdChannelListener
interface. The
MessageRouter
class
collects all published messages. When a new message channel listener is added, it receives all
collected messages from the message history.
The MessageRouter
code runs in a separate thread that should be started and
terminated by applications. Applications should use the start()
and
terminate()
methods to start and terminate the MessageRouter
thread
correspondingly.
For terminology see the Enterprise Integration Patterns book.