com.mischiefbox.pollserve
Class MessageHandler
java.lang.Object
|
+--com.mischiefbox.pollserve.MessageHandler
- All Implemented Interfaces:
- Runnable
- public class MessageHandler
- extends Object
- implements Runnable
Responsible for retrieving messages from the input queue, passing
them off to the proper processor thread, and sending responses back to
the output queue.
Additionally, manages the processor thread pool.
- Version:
- $Id$
- Author:
- Chris Jones
|
Field Summary |
protected int |
MAX_PROCESSORS
The maximum number of processor threads allowed. |
protected static int |
SLEEP_MILLIS
The time to sleep between fetches from the input queue. |
|
Method Summary |
void |
run()
Check for new messages on the input queue, get a new processor
thread from the processor thread pool, and pass the message to
the processor thread. |
void |
shutdown()
Shut down the message handler and the message processor thread
pool. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
SLEEP_MILLIS
protected static int SLEEP_MILLIS
- The time to sleep between fetches from the input queue.
MAX_PROCESSORS
protected int MAX_PROCESSORS
- The maximum number of processor threads allowed.
In effect, the maximum number of commands permitted to execute
at once. This number should be tuned for each installation
based on the number of requests and the type of system
(multi-processor systems or systems that implement Java
threads as microthreads will tend to do better with more
threads than single processor systems or systems that
implement Java threads as system processes).
This value is passed to the thread pool.
MessageHandler
public MessageHandler(Queue qInput,
Queue qOutput)
- Creates a new message handler.
- Parameters:
qInput - the message input queue.qOutput - the message output queue.
shutdown
public void shutdown()
- Shut down the message handler and the message processor thread
pool.
run
public void run()
- Check for new messages on the input queue, get a new processor
thread from the processor thread pool, and pass the message to
the processor thread.
- Specified by:
run in interface Runnable
Copyright © 2001 by Christopher R. Jones. All Rights Reserved.