ru.bitel.bgbilling.kernel.event

## Class Consumer

- java.lang.Object
- - ru.bitel.bgbilling.kernel.event.MessageAdapter
  - - ru.bitel.bgbilling.kernel.event.Consumer

- All Implemented Interfaces:
    javax.jms.MessageListener, EventListener<Event>

      public final class Consumer
      extends MessageAdapter
      implements javax.jms.MessageListener

  Обработчик сообщения.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected java.lang.String` | `applicationName`
    `protected EventListenerContext` | `eventListenerContext` `MessageListener.onMessage(Message)` выполняется в одном потоке `Session`.
    `protected EventProcessor` | `eventProcessor`
    `boolean` | `localSession`

    - ### Fields inherited from class ru.bitel.bgbilling.kernel.event.MessageAdapter

      `deliveryMode, priority, session, timeToLive`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Consumer(EventProcessor eventProcessor, javax.jms.Session session, java.lang.Class<? extends Event> clazz, EventType type, int moduleId, int pluginId, java.lang.String destination, java.lang.String query, boolean setMessageListener, boolean localSession)`
    `Consumer(EventProcessor eventProcessor, javax.jms.Session session, int moduleId, int pluginId, java.lang.String destination, java.lang.String query, boolean queue, boolean noLocal, int deliveryMode, int priority, long timeToLive, boolean localSession, java.lang.Class<? extends Event>... clazz)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `close()`
    `protected javax.jms.MessageConsumer` | `createConsumer(java.lang.String destination, java.lang.String query, boolean noLocal, boolean topic)`
    `void` | `destroy()`
    `void` | `notify(Event e, EventListenerContext ctx)`
    `void` | `onMessage(javax.jms.Message message)`
    `protected boolean` | `onMessage0(javax.jms.Message message, EventListenerContext eventListenerContext, EventListener<Event> listener)`
    `<E extends Event> E` | `receive()`
    `<E extends Event> E` | `receive(long timeout)`
    `<E extends Event> E` | `receiveNoWait()`
    `protected void` | `trySendReply(javax.jms.Message message, Event e, java.lang.Exception ex)`

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

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

- - ### Field Detail

    - #### eventProcessor

          protected final EventProcessor eventProcessor

    - #### applicationName

          protected final java.lang.String applicationName

    - #### eventListenerContext

          protected final EventListenerContext eventListenerContext

      `MessageListener.onMessage(Message)` выполняется в одном потоке `Session`.
      Поэтому можно использовать один объект `EventListenerContext`, если обработка в одном пакете.

    - #### localSession

          public final boolean localSession

  - ### Constructor Detail

    - #### Consumer

          public Consumer(EventProcessor eventProcessor,
                          javax.jms.Session session,
                          java.lang.Class<? extends Event> clazz,
                          EventType type,
                          int moduleId,
                          int pluginId,
                          java.lang.String destination,
                          java.lang.String query,
                          boolean setMessageListener,
                          boolean localSession)
                   throws javax.jms.JMSException,
                          javax.xml.bind.JAXBException

      Throws:
        `javax.jms.JMSException`
        `javax.xml.bind.JAXBException`

    - #### Consumer

          public Consumer(EventProcessor eventProcessor,
                          javax.jms.Session session,
                          int moduleId,
                          int pluginId,
                          java.lang.String destination,
                          java.lang.String query,
                          boolean queue,
                          boolean noLocal,
                          int deliveryMode,
                          int priority,
                          long timeToLive,
                          boolean localSession,
                          java.lang.Class<? extends Event>... clazz)
                   throws javax.jms.JMSException,
                          javax.xml.bind.JAXBException

      Throws:
        `javax.jms.JMSException`
        `javax.xml.bind.JAXBException`

  - ### Method Detail

    - #### onMessage0

          protected boolean onMessage0(javax.jms.Message message,
                                       EventListenerContext eventListenerContext,
                                       EventListener<Event> listener)
                                throws javax.jms.JMSException,
                                       javax.xml.bind.JAXBException,
                                       ru.bitel.bgbilling.common.BGException

      Throws:
        `javax.jms.JMSException`
        `javax.xml.bind.JAXBException`
        `ru.bitel.bgbilling.common.BGException`

    - #### onMessage

          public void onMessage(javax.jms.Message message)

      Specified by:
        `onMessage` in interface `javax.jms.MessageListener`

    - #### createConsumer

          protected javax.jms.MessageConsumer createConsumer(java.lang.String destination,
                                                             java.lang.String query,
                                                             boolean noLocal,
                                                             boolean topic)
                                                      throws javax.jms.JMSException

      Throws:
        `javax.jms.JMSException`

    - #### trySendReply

          protected final void trySendReply(javax.jms.Message message,
                                            Event e,
                                            java.lang.Exception ex)
                                     throws javax.jms.JMSException,
                                            javax.xml.bind.JAXBException

      Throws:
        `javax.jms.JMSException`
        `javax.xml.bind.JAXBException`

    - #### close

          public void close()
                     throws javax.jms.JMSException

      Throws:
        `javax.jms.JMSException`

    - #### destroy

          public void destroy()
                       throws javax.jms.JMSException

      Throws:
        `javax.jms.JMSException`

    - #### receive

          public <E extends Event> E receive()
                                      throws ru.bitel.bgbilling.common.BGException

      Throws:
        `ru.bitel.bgbilling.common.BGException`

    - #### receive

          public <E extends Event> E receive(long timeout)
                                      throws ru.bitel.bgbilling.common.BGException

      Throws:
        `ru.bitel.bgbilling.common.BGException`

    - #### receiveNoWait

          public <E extends Event> E receiveNoWait()
                                            throws ru.bitel.bgbilling.common.BGException

      Throws:
        `ru.bitel.bgbilling.common.BGException`

    - #### notify

          public void notify(Event e,
                             EventListenerContext ctx)
                      throws ru.bitel.bgbilling.common.BGException

      Specified by:
        `notify` in interface `EventListener<Event>`
      Throws:
        `ru.bitel.bgbilling.common.BGException`