|
|||||||||
| Home >> All >> com >> presumo >> jms >> [ router overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
com.presumo.jms.router
Class RouterAdapter

java.lang.Objectcom.presumo.jms.router.RouterAdapter
- All Implemented Interfaces:
- java.lang.Runnable
- Direct Known Subclasses:
- Router
- public abstract class RouterAdapter
- extends java.lang.Object
- implements java.lang.Runnable
- extends java.lang.Object
Class to represent the functionality of starting stoping and closing a thread that is doing routing. This handles all of the multithreading logic for the router, and was pulled out to an abstract base class to simplify the actual Router implementation. WARNING: If you change ANYTHING in this class unit test!!!!!
| Field Summary | |
private int |
batchSize
|
private boolean |
closed
|
private com.presumo.jms.plugin.MessageQueue |
inbox
|
private static com.presumo.util.log.Logger |
logger
|
private java.lang.Object |
routerLock
|
private java.lang.Thread |
routingThread
|
private java.lang.Object |
startStopLock
|
private boolean |
stopRouting
|
private java.lang.String |
threadName
|
| Constructor Summary | |
RouterAdapter(com.presumo.jms.plugin.MessageQueue queue,
int batchSize,
java.lang.String threadName)
|
|
| Method Summary | |
void |
closeRouter()
|
protected com.presumo.jms.message.JmsMessage[] |
getNext(int batchsize)
|
protected void |
queueMessage(com.presumo.jms.message.JmsMessage msg)
Puts a message on the queue and notifies the routing thread. |
protected void |
queueMessages(com.presumo.jms.message.JmsMessage[] msgs)
Puts an array of messages on the queue and notifies the routing thread. |
protected int |
queueSize()
|
protected abstract void |
routeMessages(int number)
Subclasses of this adapter implement this method to add the final piece of functionality. |
void |
run()
Implementation of runnable. |
void |
setBatchSize(int batchSize)
The size of batches which the router processes messages is a potential touch point. |
void |
setMessageQueue(com.presumo.jms.plugin.MessageQueue queue)
|
void |
startRouter()
Starts the delivery of asynchronous messages. |
void |
stopRouter()
Stops the delivery of asynchronous messages. |
protected void |
timerTick()
Called when the routing thread has done nothing for a while |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
closed
private volatile boolean closed
stopRouting
private volatile boolean stopRouting
batchSize
private int batchSize
startStopLock
private final java.lang.Object startStopLock
routerLock
private final java.lang.Object routerLock
routingThread
private java.lang.Thread routingThread
threadName
private final java.lang.String threadName
inbox
private com.presumo.jms.plugin.MessageQueue inbox
logger
private static com.presumo.util.log.Logger logger
| Constructor Detail |
RouterAdapter
public RouterAdapter(com.presumo.jms.plugin.MessageQueue queue, int batchSize, java.lang.String threadName)
| Method Detail |
run
public void run()
- Implementation of runnable. The method will remain in the loop until
closeRouter() is called. This loop will call routeMessages() while
there are messages to be routed. If there are no messages to be routed
the thread will wait() on the inbox until there are messages.
- Specified by:
runin interfacejava.lang.Runnable
setMessageQueue
public void setMessageQueue(com.presumo.jms.plugin.MessageQueue queue)
closeRouter
public void closeRouter()
startRouter
public void startRouter()
- Starts the delivery of asynchronous messages.
stopRouter
public void stopRouter()
- Stops the delivery of asynchronous messages.
setBatchSize
public void setBatchSize(int batchSize)
- The size of batches which the router processes messages is a potential
touch point. Consequently I'm making it configurable on the fly.
routeMessages
protected abstract void routeMessages(int number)
- Subclasses of this adapter implement this method to add the final
piece of functionality. The thread embedded in this class will
call this method when there are messages on the inbox that need
to be routed.
timerTick
protected void timerTick()
- Called when the routing thread has done nothing for a while
getNext
protected final com.presumo.jms.message.JmsMessage[] getNext(int batchsize) throws java.io.IOException
queueSize
protected final int queueSize()
queueMessage
protected final void queueMessage(com.presumo.jms.message.JmsMessage msg) throws java.io.IOException
- Puts a message on the queue and notifies the routing thread.
queueMessages
protected final void queueMessages(com.presumo.jms.message.JmsMessage[] msgs) throws java.io.IOException
- Puts an array of messages on the queue and notifies the routing thread.
|
|||||||||
| Home >> All >> com >> presumo >> jms >> [ router overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC
com.presumo.jms.router.RouterAdapter