Package ru.bitel.bgbilling.kernel.event
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:
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
Modifier and TypeFieldDescriptionprotected long
protected int
protected long
protected final boolean
protected long
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
ConstructorDescriptionAsyncEventWorker
(EventProcessor ep, Class<? extends ru.bitel.bgbilling.kernel.event.common.Event> clazz, int moduleId, int pluginId, String query) AsyncEventWorker
(EventProcessor ep, String destination, int moduleId, int pluginId, String query, boolean autoAcknowledge, Class<?>... clazz) -
Method Summary
Modifier and TypeMethodDescriptionboolean
doTasks()
Выполнение задач (одной или нескольких, с ожиданием новых в теченииEventWorker.batchWait
), нужно вызывать изEventWorker.runWorker()
.protected boolean
internalDoTask
(Object task) void
notify
(ru.bitel.bgbilling.kernel.event.common.Event task, EventListenerContext ctx) protected Object
poll
(long timeout) protected void
processDoTaskException
(Object task, boolean inDoTask, boolean putFirstIfInDoTask, ru.bitel.bgbilling.common.BGException ex, boolean throwException) protected void
protected void
protected abstract void
protected void
taskTimeout
(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
-
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, Class<? extends ru.bitel.bgbilling.kernel.event.common.Event> clazz, int moduleId, int pluginId, String query) throws ru.bitel.bgbilling.common.BGException - Throws:
ru.bitel.bgbilling.common.BGException
-
AsyncEventWorker
public AsyncEventWorker(EventProcessor ep, String destination, int moduleId, int pluginId, String query, boolean autoAcknowledge, Class<?>... clazz) throws ru.bitel.bgbilling.common.BGException - Throws:
ru.bitel.bgbilling.common.BGException
-
-
Method Details
-
poll
- Overrides:
poll
in classEventWorker
- Throws:
ru.bitel.bgbilling.common.BGException
-
putFirst
- Throws:
InterruptedException
-
putLast
- Throws:
InterruptedException
-
doTasks
public boolean doTasks() throws ru.bitel.bgbilling.common.BGExceptionDescription copied from class:EventWorker
Выполнение задач (одной или нескольких, с ожиданием новых в теченииEventWorker.batchWait
), нужно вызывать изEventWorker.runWorker()
.- Overrides:
doTasks
in classEventWorker
- Returns:
- Throws:
ru.bitel.bgbilling.common.BGException
-
internalDoTask
protected boolean internalDoTask(Object task) throws javax.jms.JMSException, jakarta.xml.bind.JAXBException, ru.bitel.bgbilling.common.BGException - Overrides:
internalDoTask
in classEventWorker
- Throws:
javax.jms.JMSException
jakarta.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 interfaceEventListener<E extends ru.bitel.bgbilling.kernel.event.common.Event>
- Overrides:
notify
in classEventWorker
- Throws:
ru.bitel.bgbilling.common.BGException
-
processDoTaskException
protected void processDoTaskException(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(Object task, Object result) throws ru.bitel.bgbilling.common.BGException - Throws:
ru.bitel.bgbilling.common.BGException
-
taskTimeout
-