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 ConnectionFactory
connFactory
protected int
count
protected long[]
delay
protected Destination
dlq
private static org.slf4j.Logger
logger
protected int
maxCount
protected String
name
protected boolean
noFail
protected String
password
protected Destination
requestQueue
protected boolean
started
protected boolean
stop
protected boolean
stopped
protected String
username
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clearMessages()
protected JMSContext
createContext(Integer sessionMode)
void
execute()
int
getCount()
boolean
isStarted()
boolean
isStopped()
static void
main(String[] args)
void
run()
void
setConnFactory(ConnectionFactory connFactory)
void
setDLQ(Destination dlq)
void
setMaxCount(int maxCount)
void
setNoFail(boolean noFail)
void
setPassword(String password)
void
setRequestQueue(Destination requestQueue)
void
setUsername(String username)
void
stop()
-
-
-
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)
-
-