A Queue class acts as an event filter. It listens for events and places those events on a queue. Another thread pulls events from that queue and rebroadcasts them to the queue’s listeners. This means that you can interpose a Queue between two components that originally had an event source/event listener relationship.

For example, say that component A generates LogEvents and broadcasts them to any listeners. Component B listens for LogEvents from A and writes the log events to a log:

A -> B -> file

Now say that component B is starting to hamper the throughput of component A because of the time required to write to a file. The solution is to interpose a LogListenerQueue as component Q:

A -> Q -> B -> file

This can be done purely through changing configuration files. Neither components A nor B need to know that there is a queue sitting between them.

The original configuration files for A and B might look like this:

A.properties:

$class=blah.blah.LoggingSource
logListeners=B

B.properties:

$class=atg.nucleus.logging.FileLogger
logFileName=events.log

With the queue component interposed, the configuration files look like this:

A.properties:

$class=blah.blah.LoggingSource
logListeners=Q

Q.properties:

$class=atg.nucleus.logging.LogListenerQueue
logListeners=B

B.properties:

$class=atg.nucleus.logging.FileLogger
logFileName=events.log

Copyright © 1997, 2012 Oracle and/or its affiliates. All rights reserved.

Legal Notices