Package ejava.examples.jmsscheduler
Class Worker
- java.lang.Object
-
- ejava.examples.jmsscheduler.Worker
-
- All Implemented Interfaces:
Runnable
public class Worker extends Object implements Runnable
This class simulates the job of a worker. It will attempt to take a message off the queue, work on it, and issue a reply. The length of time taken on each message will vary per message based on a difficulty index. The worker will quite when it hits its max value; always failing to repond to the last request processed (on purpose).
-
-
Field Summary
Fields Modifier and Type Field Description protected ConnectionFactoryconnFactoryprotected intcountprotected long[]delayprotected Destinationdlqprivate static org.slf4j.Loggerloggerprotected intmaxCountprotected Stringnameprotected booleannoFailprotected Stringpasswordprotected DestinationrequestQueueprotected booleanstartedprotected booleanstopprotected booleanstoppedprotected Stringusername
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclearMessages()protected JMSContextcreateContext(Integer sessionMode)voidexecute()intgetCount()booleanisStarted()booleanisStopped()static voidmain(String[] args)voidrun()voidsetConnFactory(ConnectionFactory connFactory)voidsetDLQ(Destination dlq)voidsetMaxCount(int maxCount)voidsetNoFail(boolean noFail)voidsetPassword(String password)voidsetRequestQueue(Destination requestQueue)voidsetUsername(String username)voidstop()
-
-
-
Field Detail
-
logger
private static final org.slf4j.Logger logger
-
connFactory
protected ConnectionFactory connFactory
-
requestQueue
protected Destination requestQueue
-
dlq
protected Destination dlq
-
stop
protected boolean stop
-
stopped
protected boolean stopped
-
started
protected boolean started
-
noFail
protected boolean noFail
-
name
protected String name
-
count
protected int count
-
maxCount
protected int maxCount
-
delay
protected long[] delay
-
username
protected String username
-
password
protected String password
-
-
Constructor Detail
-
Worker
public Worker(String name)
-
-
Method Detail
-
setConnFactory
public void setConnFactory(ConnectionFactory connFactory)
-
setRequestQueue
public void setRequestQueue(Destination requestQueue)
-
setDLQ
public void setDLQ(Destination dlq)
-
getCount
public int getCount()
-
setMaxCount
public void setMaxCount(int maxCount)
-
clearMessages
public void clearMessages()
-
stop
public void stop()
-
isStopped
public boolean isStopped()
-
isStarted
public boolean isStarted()
-
setNoFail
public void setNoFail(boolean noFail)
-
createContext
protected JMSContext createContext(Integer sessionMode) throws Exception
- Throws:
Exception
-
setUsername
public void setUsername(String username)
-
setPassword
public void setPassword(String password)
-
main
public static void main(String[] args)
-
-