org.apache.uima.adapter.jms.activemq

## Class PriorityMessageHandler

- java.lang.Object
- - org.apache.uima.adapter.jms.activemq.PriorityMessageHandler

- All Implemented Interfaces:
    org.springframework.jms.listener.SessionAwareMessageListener

      public class PriorityMessageHandler
      extends Object
      implements org.springframework.jms.listener.SessionAwareMessageListener

  This class main job is to receive a JMS message from Spring Listeners via onMessage() and wrapping it in a MessageWrapper before enqueuing that onto a BlockingPriorityQueue for process threads. Only two listener types send messages to this class: Targeted Listener and Process Listener. For targeted listener this class creates a dedicated semaphore with 1 permit. For process listener this class creates a dedicated semaphore with a number of permits equal to scaleout (# of process threads). The listener thread calling onMessage() will try to acquire its semaphore and will block if no permits are available. The targeted listener is identified by value returned from message.getJMSType(). This is set in UimaDefaultMessageListenerContainer.doInvokeListener() before this class onMessage() is called.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `PriorityMessageHandler(int scaleout)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `BlockingQueue<org.apache.uima.aae.message.MessageWrapper>` | `getQueue()`
    `void` | `onMessage(javax.jms.Message message, javax.jms.Session session)` Wraps an incoming message in a protocol neutral envelope and adds priority value to enable sorting in a Priority Queue.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### PriorityMessageHandler

          public PriorityMessageHandler(int scaleout)

  - ### Method Detail

    - #### getQueue

          public BlockingQueue<org.apache.uima.aae.message.MessageWrapper> getQueue()

    - #### onMessage

          public void onMessage(javax.jms.Message message,
                                javax.jms.Session session)
                         throws javax.jms.JMSException

      Wraps an incoming message in a protocol neutral envelope and adds priority value to enable sorting in a Priority Queue. Messages specifically targetting an instance of a service will be assigned high priority for processing.
      Specified by:
        `onMessage` in interface `org.springframework.jms.listener.SessionAwareMessageListener`
      Throws:
        `javax.jms.JMSException`

Copyright © 2006–2018 The Apache Software Foundation. All rights reserved.