ru.bitel.bgbilling.kernel.event

## Class EventWorker

- java.lang.Object
- - ru.bitel.common.worker.WorkerTask<EventListenerContext>
  - - ru.bitel.bgbilling.kernel.event.EventWorker

- All Implemented Interfaces:
    java.lang.Runnable, EventListener<Event>
  Direct Known Subclasses:
    AsyncEventWorker, TvAccountStateAndOptionsDatabaseWorker

      public abstract class EventWorker
      extends ru.bitel.common.worker.WorkerTask<EventListenerContext>
      implements EventListener<Event>

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected long` | `batchWait`
    `protected ru.bitel.bgbilling.kernel.event.AbstractConsumer` | `consumer`
    `protected long` | `errorPause`
    `protected int` | `moduleId`
    `protected boolean` | `working`

    - ### Fields inherited from class ru.bitel.common.worker.WorkerTask

      `context`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `` | `EventWorker(EventProcessor ep, java.lang.Class<? extends Event> clazz, int moduleId, int pluginId, java.lang.String query)`
    `` | `EventWorker(EventProcessor ep, java.lang.String destination, int moduleId, int pluginId, java.lang.String query, boolean autoAcknowledge, java.lang.Class<?>... clazz)`
    `protected` | `EventWorker(int moduleId)`

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `abstract java.lang.Object` | `doTask(java.lang.Object task)`
    `boolean` | `doTasks()`
    `protected boolean` | `internalDoTask(java.lang.Object task)`
    `protected int` | `internalRunWorker(long timeout, boolean wait)`
    `void` | `notify(Event e, EventListenerContext ctx)`
    `protected java.lang.Object` | `poll(long timeout)`
    `protected java.lang.Object` | `pollFirstTask()`
    `protected void` | `runImpl()`
    `protected abstract boolean` | `runWorker()`
    `void` | `setConsumer(java.lang.Class<? extends Event> clazz, java.lang.String query)`
    `void` | `shutdown()`

    - ### Methods inherited from class ru.bitel.common.worker.WorkerTask

      `newBlockingFixedThreadPool, newFixedThreadPool, newFixedThreadPool, newScheduledThreadPool, run, runSync, runSync, setContext`

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

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

- - ### Field Detail

    - #### consumer

          protected ru.bitel.bgbilling.kernel.event.AbstractConsumer consumer

    - #### batchWait

          protected long batchWait

    - #### errorPause

          protected long errorPause

    - #### working

          protected volatile boolean working

    - #### moduleId

          protected final int moduleId

  - ### Constructor Detail

    - #### EventWorker

          protected EventWorker(int moduleId)
                         throws ru.bitel.bgbilling.common.BGException

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

    - #### EventWorker

          public EventWorker(EventProcessor ep,
                             java.lang.Class<? extends Event> clazz,
                             int moduleId,
                             int pluginId,
                             java.lang.String query)
                      throws ru.bitel.bgbilling.common.BGException

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

    - #### EventWorker

          public EventWorker(EventProcessor ep,
                             java.lang.String destination,
                             int moduleId,
                             int pluginId,
                             java.lang.String query,
                             boolean autoAcknowledge,
                             java.lang.Class<?>... clazz)
                      throws ru.bitel.bgbilling.common.BGException

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

  - ### Method Detail

    - #### setConsumer

          public void setConsumer(java.lang.Class<? extends Event> clazz,
                                  java.lang.String query)
                           throws ru.bitel.bgbilling.common.BGException

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

    - #### runImpl

          protected void runImpl()
                          throws java.lang.Exception

      Specified by:
        `runImpl` in class `ru.bitel.common.worker.WorkerTask<EventListenerContext>`
      Throws:
        `java.lang.Exception`

    - #### internalRunWorker

          protected int internalRunWorker(long timeout,
                                          boolean wait)

      Parameters:
        `timeout` -
        `wait` -
      Returns:
        -1, если произошла ошибка; 0, если ничего не было сделано, 1, если нормально выполнено одно или более заданий.

    - #### pollFirstTask

          protected java.lang.Object pollFirstTask()

    - #### poll

          protected java.lang.Object poll(long timeout)
                                   throws ru.bitel.bgbilling.common.BGException

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

    - #### doTasks

          public boolean doTasks()
                          throws ru.bitel.bgbilling.common.BGException

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

    - #### internalDoTask

          protected boolean internalDoTask(java.lang.Object task)
                                    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`

    - #### runWorker

          protected abstract boolean runWorker()
                                        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`

    - #### doTask

          public abstract java.lang.Object doTask(java.lang.Object task)
                                           throws ru.bitel.bgbilling.common.BGException

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

    - #### shutdown

          public void shutdown()
                        throws ru.bitel.bgbilling.common.BGException

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