Class AsyncEventWorker<E extends ru.bitel.bgbilling.kernel.event.common.Event>

java.lang.Object
ru.bitel.common.worker.WorkerTask<EventListenerContext>
ru.bitel.bgbilling.kernel.event.EventWorker
ru.bitel.bgbilling.kernel.event.AsyncEventWorker<E>
Type Parameters:
E -
All Implemented Interfaces:
java.lang.Runnable, EventListener<ru.bitel.bgbilling.kernel.event.common.Event>

public abstract class AsyncEventWorker<E extends ru.bitel.bgbilling.kernel.event.common.Event>
extends EventWorker
Асинхронный обработчик событий.
  • Nested Class Summary

    Nested classes/interfaces inherited from class ru.bitel.common.worker.WorkerTask

    ru.bitel.common.worker.WorkerTask.BlockingExecutionHandler
  • Field Summary

    Fields
    Modifier and Type Field Description
    protected long batchPause  
    protected int batchSize  
    protected long errorCount  
    protected boolean needAcknowledge  
    protected long waitNextTask  

    Fields inherited from class ru.bitel.bgbilling.kernel.event.EventWorker

    batchWait, consumer, errorPause, moduleId, working

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

    context
  • Constructor Summary

    Constructors
    Constructor Description
    AsyncEventWorker​(EventProcessor ep, java.lang.Class<? extends ru.bitel.bgbilling.kernel.event.common.Event> clazz, int moduleId, int pluginId, java.lang.String query)  
    AsyncEventWorker​(EventProcessor ep, java.lang.String destination, int moduleId, int pluginId, java.lang.String query, boolean autoAcknowledge, java.lang.Class<?>... clazz)  
  • Method Summary

    Modifier and Type Method Description
    boolean doTasks()
    Выполнение задач (одной или нескольких, с ожиданием новых в течении EventWorker.batchWait), нужно вызывать из EventWorker.runWorker().
    protected boolean internalDoTask​(java.lang.Object task)  
    void notify​(ru.bitel.bgbilling.kernel.event.common.Event task, EventListenerContext ctx)  
    protected java.lang.Object poll​(long timeout)  
    protected void processDoTaskException​(java.lang.Object task, boolean inDoTask, boolean putFirstIfInDoTask, ru.bitel.bgbilling.common.BGException ex, boolean throwException)  
    protected void putFirst​(java.lang.Object task)  
    protected void putLast​(java.lang.Object task)  
    protected abstract void taskDone​(java.lang.Object task, java.lang.Object result)  
    protected void taskTimeout​(java.lang.Object task)  

    Methods inherited from class ru.bitel.bgbilling.kernel.event.EventWorker

    doTask, internalRunWorker, pollFirstTask, runImpl, runWorker, setConsumer, 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 Details

    • waitNextTask

      protected long waitNextTask
    • batchSize

      protected int batchSize
    • batchPause

      protected long batchPause
    • needAcknowledge

      protected final boolean needAcknowledge
    • errorCount

      protected long errorCount
  • Constructor Details

    • AsyncEventWorker

      public AsyncEventWorker​(EventProcessor ep, java.lang.Class<? extends ru.bitel.bgbilling.kernel.event.common.Event> clazz, int moduleId, int pluginId, java.lang.String query) throws ru.bitel.bgbilling.common.BGException
      Throws:
      ru.bitel.bgbilling.common.BGException
    • AsyncEventWorker

      public AsyncEventWorker​(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 Details

    • poll

      protected java.lang.Object poll​(long timeout) throws ru.bitel.bgbilling.common.BGException
      Overrides:
      poll in class EventWorker
      Throws:
      ru.bitel.bgbilling.common.BGException
    • putFirst

      protected void putFirst​(java.lang.Object task) throws java.lang.InterruptedException
      Throws:
      java.lang.InterruptedException
    • putLast

      protected void putLast​(java.lang.Object task) throws java.lang.InterruptedException
      Throws:
      java.lang.InterruptedException
    • doTasks

      public boolean doTasks() throws ru.bitel.bgbilling.common.BGException
      Description copied from class: EventWorker
      Выполнение задач (одной или нескольких, с ожиданием новых в течении EventWorker.batchWait), нужно вызывать из EventWorker.runWorker().
      Overrides:
      doTasks in class EventWorker
      Returns:
      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
      Overrides:
      internalDoTask in class EventWorker
      Throws:
      javax.jms.JMSException
      javax.xml.bind.JAXBException
      ru.bitel.bgbilling.common.BGException
    • notify

      public void notify​(ru.bitel.bgbilling.kernel.event.common.Event task, EventListenerContext ctx) throws ru.bitel.bgbilling.common.BGException
      Specified by:
      notify in interface EventListener<E extends ru.bitel.bgbilling.kernel.event.common.Event>
      Overrides:
      notify in class EventWorker
      Throws:
      ru.bitel.bgbilling.common.BGException
    • processDoTaskException

      protected void processDoTaskException​(java.lang.Object task, boolean inDoTask, boolean putFirstIfInDoTask, ru.bitel.bgbilling.common.BGException ex, boolean throwException) throws ru.bitel.bgbilling.common.BGException
      Parameters:
      task -
      inDoTask - ошибка произошла в doTask или позже
      putFirstIfInDoTask -
      ex -
      throwException -
      Throws:
      ru.bitel.bgbilling.common.BGException
    • taskDone

      protected abstract void taskDone​(java.lang.Object task, java.lang.Object result) throws ru.bitel.bgbilling.common.BGException
      Throws:
      ru.bitel.bgbilling.common.BGException
    • taskTimeout

      protected void taskTimeout​(java.lang.Object task)