Class BaseMessageSender
java.lang.Object
org.apache.uima.adapter.jms.client.BaseMessageSender
- All Implemented Interfaces:
Runnable
,MessageSender
- Direct Known Subclasses:
ActiveMQMessageSender
Creates a worker thread for sending messages. This is an abstract implementation that provides a
thread with run logic. The concrete implementation of the Worker Thread must extend this class.
The application threads share a special in-memory queue with this worker thread. The application
threads add jms messages to the pendingMessageList queue and the worker thread consumes them. The
worker thread terminates when the uima ee client calls doStop() method.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected boolean
protected BaseUIMAAsynchronousEngineCommon_impl
protected Exception
protected BlockingQueue<PendingMessage>
protected boolean
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract void
cleanup()
void
doStop()
Stops the worker threadboolean
failed()
The uima ee client should call this method to check if there was a failure.protected abstract String
abstract javax.jms.MessageProducer
javax.jms.MessageProducer
getMessageProducer
(javax.jms.Destination destination) Return the Exception that caused the failure in this worker threadprotected abstract void
void
run()
Initializes jms message producer and starts the main thread.abstract void
setConnection
(javax.jms.Connection connection) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.apache.uima.adapter.jms.client.MessageSender
createBytesMessage, createTextMessage
-
Field Details
-
messageQueue
-
done
protected volatile boolean done -
engine
-
workerThreadFailed
protected volatile boolean workerThreadFailed -
exception
-
-
Constructor Details
-
BaseMessageSender
-
-
Method Details
-
getMessageProducer
public abstract javax.jms.MessageProducer getMessageProducer()- Specified by:
getMessageProducer
in interfaceMessageSender
-
initializeProducer
- Throws:
Exception
-
cleanup
- Throws:
Exception
-
getDestinationEndpoint
- Throws:
Exception
-
setConnection
public abstract void setConnection(javax.jms.Connection connection) - Specified by:
setConnection
in interfaceMessageSender
-
doStop
public void doStop()Stops the worker thread- Specified by:
doStop
in interfaceMessageSender
-
getReasonForFailure
Return the Exception that caused the failure in this worker thread- Specified by:
getReasonForFailure
in interfaceMessageSender
- Returns:
- - Exception
-
failed
public boolean failed()The uima ee client should call this method to check if there was a failure. The method returns true if there was a failure or false otherwise. If true, the uima ee client can call getReasonForFailure() to get the reason for failure- Specified by:
failed
in interfaceMessageSender
-
run
public void run()Initializes jms message producer and starts the main thread. This thread waits for messages enqueued by application threads. The application thread adds a jms message to the pendingMessageList 'queue' and signals this worker that there is a new message. The worker thread removes the message and sends it out to a given destination. All messages should be fully initialized The worker thread does check the message nor adds anything new to the message. It just sends it out. -
getMessageProducer
public javax.jms.MessageProducer getMessageProducer(javax.jms.Destination destination) throws Exception - Specified by:
getMessageProducer
in interfaceMessageSender
- Throws:
Exception
-