private void postEvent(ProceedingJoinPoint pjp, String type, JobExecutingData data, SystemData retVal) { if (retVal != null) { eventBus.post(retVal); } events.finished(buildId(type, data.getProcessingThread())); }
private Object executeScheduledJob(final ProceedingJoinPoint pjp, final String type) throws Throwable { addTypeToStatCounter(type); JobExecutingData data = new JobExecutingData( type, statCounter.count(type)); String id = buildId(type, data.getProcessingThread()); events.active(id, data); SystemData retVal = null; long correlationId = r.nextLong(); eventBus.post(new JobStartEvent( correlationId, type)); try { retVal = Optional.ofNullable(((SystemData) pjp.proceed())) .map(sd -> sd.withCorrelationId(id)) .orElse(null); return retVal; } finally { logSystemEvent(pjp, type, data, retVal); retVal = Optional.ofNullable(retVal) .orElse(SystemData.builder() .correlationId("" + correlationId) .errors(0l) .processed(0l) .build()); eventBus.post(new JobCompleteEvent( correlationId, type, retVal.getErrors(), retVal.getProcessed())); } }
private void postEvent(ProceedingJoinPoint pjp, String type, JobExecutingData data, SystemData retVal) { if (retVal != null) { eventBus.post(retVal); } events.finished(buildId(type, data.getProcessingThread())); }
private Object executeScheduledJob(final ProceedingJoinPoint pjp, final String type) throws Throwable { addTypeToStatCounter(type); JobExecutingData data = new JobExecutingData( type, statCounter.count(type)); String id = buildId(type, data.getProcessingThread()); events.active(id, data); SystemData retVal = null; long correlationId = r.nextLong(); eventBus.post(new JobStartEvent( correlationId, type)); try { retVal = Optional.ofNullable(((SystemData) pjp.proceed())) .map(sd -> sd.withCorrelationId(id)) .orElse(null); return retVal; } finally { logSystemEvent(pjp, type, data, retVal); retVal = Optional.ofNullable(retVal) .orElse(SystemData.builder() .correlationId("" + correlationId) .errors(0l) .processed(0l) .build()); eventBus.post(new JobCompleteEvent( correlationId, type, retVal.getErrors(), retVal.getProcessed())); } }