code: private void processEventQueue(final TaskRec head) {
  		final TedResult headResult = processEvent(head);
  		TaskConfig tc = context.registry.getTaskConfig(head.name);
  		if (tc == null) {
  			context.taskManager.handleUnknownTasks(asList(head));
  			return;
  		}
  
  		TaskRec lastUnsavedEvent = null;
  		TedResult lastUnsavedResult = null;
  		// try to execute next events, while head is reserved. some events may be created while executing current
  		if (headResult.status == TedStatus.DONE) {
  			outer:
  			for (int i = 0; i < 10; i++) {
  				List<TaskRec> events = tedDaoExt.eventQueueGetTail(head.key1);
  				if (events.isEmpty())
  					break outer;
  				for (TaskRec event : events) {
  					TaskConfig tc2 = context.registry.getTaskConfig(event.name);
  					if (tc2 == null)
  						break outer; // unknown task, leave it for later
  
  					TedResult result = processEvent(event);
  
  					// DONE - final status, on which can continue with next event
  					if (result.status == TedStatus.DONE) {
  						saveResult(event, result);
  					} else {
  						lastUnsavedEvent = event;
  						lastUnsavedResult = result;
  						break outer;
  					}
  				}
  			}
  		}
  
  		// first save head, otherwise unique index will fail
  		final TedResult finalLastUnsavedResult = lastUnsavedResult;
  		final TaskRec finalLastUnsavedEvent = lastUnsavedEvent;
  		tedDaoExt.runInTx(new Runnable() {
  			@Override
  			public void run() {
  				try {
  					saveResult(head, headResult);
  					if (finalLastUnsavedResult != null) {
  						saveResult(finalLastUnsavedEvent, finalLastUnsavedResult);
  					}
  				} catch (Exception e) {
  					logger.error("Error while finishing events queue execution", e);
  				}
  			}
  		});
  	}
docs: process events from queue each after other, until ERROR or RETRY will happen