|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.lang.Thread
org.apache.commons.messagelet.ConsumerThread
public class ConsumerThread
ConsumerThread
is a thread which will repeatedly consume JMS messages
using a receive() method on Messenger and then process the message.
This class is a good base class when implementing some kind of transactional processing of
JMS messages
Nested Class Summary |
---|
Nested classes/interfaces inherited from class java.lang.Thread |
---|
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler |
Field Summary | |
---|---|
private javax.jms.MessageConsumer |
consumer
|
private javax.jms.Destination |
destination
|
private javax.jms.MessageListener |
listener
|
private static org.apache.commons.logging.Log |
log
Logger |
private Messenger |
messenger
|
private java.lang.String |
selector
|
private boolean |
shouldStop
|
Fields inherited from class java.lang.Thread |
---|
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
Constructor Summary | |
---|---|
ConsumerThread()
|
Method Summary | |
---|---|
protected void |
cancelTransaction()
Strategy method to represent the code required to cancel a transaction. |
protected void |
commitTransaction()
Strategy method to represent the code required to commit a transaction. |
protected javax.jms.MessageConsumer |
createConsumer()
Factory method to create a new MessageConsumer |
protected javax.jms.MessageConsumer |
getConsumer()
|
javax.jms.Destination |
getDestination()
Returns the destination. |
javax.jms.MessageListener |
getListener()
Returns the listener. |
Messenger |
getMessenger()
Returns the messenger. |
java.lang.String |
getSelector()
Returns the selector. |
boolean |
isShouldStop()
Returns the shouldStop. |
protected void |
processMessage(javax.jms.Message message)
Strategy method to process a given message. |
private javax.jms.Message |
receive()
Strategy method to consume a message using a receive() kind of method. |
protected void |
rollbackTransaction(java.lang.Exception e)
Strategy method to represent the code required to rollback a transaction. |
void |
run()
Starts all the JMS connections and consumes JMS messages, passing them onto the MessageListener and Message Driven Objects |
void |
setDestination(javax.jms.Destination destination)
Sets the destination. |
void |
setListener(javax.jms.MessageListener listener)
Sets the listener. |
void |
setMessenger(Messenger messenger)
Sets the messenger. |
void |
setSelector(java.lang.String selector)
Sets the selector. |
void |
setShouldStop(boolean shouldStop)
Sets the shouldStop. |
protected void |
startConsumer()
Starts consuming messages |
protected void |
startTransaction()
Strategy method to represent the code required to start a transaction. |
protected void |
stopConsumer()
Stops consuming messages |
Methods inherited from class java.lang.Thread |
---|
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private static final org.apache.commons.logging.Log log
private javax.jms.MessageConsumer consumer
private Messenger messenger
private javax.jms.Destination destination
private java.lang.String selector
private javax.jms.MessageListener listener
private boolean shouldStop
Constructor Detail |
---|
public ConsumerThread()
Method Detail |
---|
public void run()
run
in interface java.lang.Runnable
run
in class java.lang.Thread
public javax.jms.Destination getDestination()
public javax.jms.MessageListener getListener()
public Messenger getMessenger()
public java.lang.String getSelector()
public boolean isShouldStop()
public void setDestination(javax.jms.Destination destination)
destination
- The destination to setpublic void setListener(javax.jms.MessageListener listener)
listener
- The listener to setpublic void setMessenger(Messenger messenger)
messenger
- The messenger to setpublic void setSelector(java.lang.String selector)
selector
- The selector to setpublic void setShouldStop(boolean shouldStop)
shouldStop
- The shouldStop to setprotected void startConsumer() throws javax.jms.JMSException
javax.jms.JMSException
protected void stopConsumer() throws javax.jms.JMSException
javax.jms.JMSException
protected javax.jms.MessageConsumer createConsumer() throws javax.jms.JMSException
javax.jms.JMSException
private javax.jms.Message receive() throws javax.jms.JMSException
javax.jms.JMSException
protected void processMessage(javax.jms.Message message) throws javax.jms.JMSException
javax.jms.JMSException
protected void startTransaction() throws java.lang.Exception
java.lang.Exception
protected void commitTransaction() throws java.lang.Exception
java.lang.Exception
protected void rollbackTransaction(java.lang.Exception e)
protected void cancelTransaction() throws java.lang.Exception
java.lang.Exception
protected javax.jms.MessageConsumer getConsumer()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |