Class BaseMessageSender

java.lang.Object
org.apache.uima.adapter.jms.client.BaseMessageSender
All Implemented Interfaces:
Runnable, MessageSender
Direct Known Subclasses:
ActiveMQMessageSender

public abstract class BaseMessageSender extends Object implements 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 Details

  • Constructor Details

  • Method Details

    • getMessageProducer

      public abstract javax.jms.MessageProducer getMessageProducer()
      Specified by:
      getMessageProducer in interface MessageSender
    • initializeProducer

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

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

      protected abstract String getDestinationEndpoint() throws Exception
      Throws:
      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 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 Runnable
    • getMessageProducer

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