Class BaseMessageSender

  • All Implemented Interfaces:
    java.lang.Runnable, MessageSender
    Direct Known Subclasses:
    ActiveMQMessageSender

    public abstract class BaseMessageSender
    extends java.lang.Object
    implements java.lang.Runnable, MessageSender
    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 Detail

      • messageQueue

        protected java.util.concurrent.BlockingQueue<PendingMessage> messageQueue
      • done

        protected volatile boolean done
      • workerThreadFailed

        protected volatile boolean workerThreadFailed
      • exception

        protected java.lang.Exception exception
    • Method Detail

      • initializeProducer

        protected abstract void initializeProducer()
                                            throws java.lang.Exception
        Throws:
        java.lang.Exception
      • cleanup

        protected abstract void cleanup()
                                 throws java.lang.Exception
        Throws:
        java.lang.Exception
      • getDestinationEndpoint

        protected abstract java.lang.String getDestinationEndpoint()
                                                            throws java.lang.Exception
        Throws:
        java.lang.Exception
      • setConnection

        public abstract void setConnection​(javax.jms.Connection connection)
        Specified by:
        setConnection in interface MessageSender
      • doStop

        public void doStop()
        Stops the worker thread
        Specified by:
        doStop in interface MessageSender
      • getReasonForFailure

        public java.lang.Exception getReasonForFailure()
        Return the Exception that caused the failure in this worker thread
        Specified by:
        getReasonForFailure in interface MessageSender
        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 interface MessageSender
      • 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.
        Specified by:
        run in interface java.lang.Runnable
      • getMessageProducer

        public javax.jms.MessageProducer getMessageProducer​(javax.jms.Destination destination)
                                                     throws java.lang.Exception
        Specified by:
        getMessageProducer in interface MessageSender
        Throws:
        java.lang.Exception