use of sirius.db.jdbc.batch.InsertQuery in project sirius-biz by scireum.
the class EventRecorder method process.
/**
* Processes the queued events by creating a {@link BatchContext} and batch-inserting all events.
*
* @return the number of inserted events
*/
protected int process() {
lastProcessed = LocalDateTime.now();
int processedEvents = 0;
try (BatchContext ctx = new BatchContext(() -> "Process recorded events.", Duration.ofMinutes(1))) {
Map<Class<? extends Event>, InsertQuery<Event>> queries = new HashMap<>();
Event nextEvent = fetchBufferedEvent();
while (nextEvent != null) {
processEvent(ctx, queries, nextEvent);
if (++processedEvents >= MAX_EVENTS_PER_PROCESS) {
return processedEvents;
}
nextEvent = fetchBufferedEvent();
}
} catch (HandledException e) {
Exceptions.ignore(e);
} catch (Exception e) {
Exceptions.handle(Log.BACKGROUND, e);
}
return processedEvents;
}
Aggregations