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 booleanprotected BaseUIMAAsynchronousEngineCommon_implprotected Exceptionprotected BlockingQueue<PendingMessage>protected boolean -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract voidcleanup()voiddoStop()Stops the worker threadbooleanfailed()The uima ee client should call this method to check if there was a failure.protected abstract Stringabstract javax.jms.MessageProducerjavax.jms.MessageProducergetMessageProducer(javax.jms.Destination destination) Return the Exception that caused the failure in this worker threadprotected abstract voidvoidrun()Initializes jms message producer and starts the main thread.abstract voidsetConnection(javax.jms.Connection connection) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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:
getMessageProducerin interfaceMessageSender
-
initializeProducer
- Throws:
Exception
-
cleanup
- Throws:
Exception
-
getDestinationEndpoint
- Throws:
Exception
-
setConnection
public abstract void setConnection(javax.jms.Connection connection) - Specified by:
setConnectionin interfaceMessageSender
-
doStop
public void doStop()Stops the worker thread- Specified by:
doStopin interfaceMessageSender
-
getReasonForFailure
Return the Exception that caused the failure in this worker thread- Specified by:
getReasonForFailurein 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:
failedin 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:
getMessageProducerin interfaceMessageSender- Throws:
Exception
-