@Test void testAbortResilience() { Operation operation1 = ImmutableOperation.builder() .processId(OPERATION_ID_1) .startedAt(epochMillisToZonedDateTime(TIME_BEFORE_EXPIRATION_1)) .state(null) .build(); Operation operation2 = ImmutableOperation.builder() .processId(OPERATION_ID_2) .startedAt(epochMillisToZonedDateTime(TIME_BEFORE_EXPIRATION_2)) .state(null) .build(); List<Operation> operationsList = List.of(operation1, operation2); when(operationService.createQuery()).thenReturn(operationQuery); initQueryMockForPage(0, operationsList); doThrow(new FlowableOptimisticLockingException("I'm an exception")).when(flowableFacade) .deleteProcessInstance(eq(OPERATION_ID_1), any()); cleaner.execute(EXPIRATION_TIME); verify(historicOperationEventService).add(ImmutableHistoricOperationEvent.of(OPERATION_ID_1, HistoricOperationEvent.EventType.ABORTED)); verify(historicOperationEventService).add(ImmutableHistoricOperationEvent.of(OPERATION_ID_2, HistoricOperationEvent.EventType.ABORTED)); }
@Override public void execute(Date expirationTime) { LOGGER.debug(CleanUpJob.LOG_MARKER, format(Messages.DELETING_OPERATIONS_STARTED_BEFORE_0, expirationTime)); int abortedOperations = abortActiveOperations(expirationTime); LOGGER.info(CleanUpJob.LOG_MARKER, format(Messages.ABORTED_OPERATIONS_0, abortedOperations)); int deletedOperations = operationService.createQuery() .startedBefore(expirationTime) .inFinalState() .delete(); LOGGER.info(CleanUpJob.LOG_MARKER, format(Messages.DELETED_OPERATIONS_0, deletedOperations)); }
OperationsCleaner implements Cleaner { @Override public void execute(Date expirationTime) { LOGGER.debug(CleanUpJob.LOG_MARKER, format(Messages.DELETING_OPERATIONS_STARTED_BEFORE_0, expirationTime)); int abortedOperations = abortActiveOperations(expirationTime); LOGGER.info(CleanUpJob.LOG_MARKER, format(Messages.ABORTED_OPERATIONS_0, abortedOperations)); int deletedOperations = operationService.createQuery() .startedBefore(expirationTime) .inFinalState() .delete(); LOGGER.info(CleanUpJob.LOG_MARKER, format(Messages.DELETED_OPERATIONS_0, deletedOperations)); } }
OperationsCleaner implements Cleaner { @Override public void execute(Date expirationTime) { LOGGER.debug(CleanUpJob.LOG_MARKER, format(Messages.DELETING_OPERATIONS_STARTED_BEFORE_0, expirationTime)); int abortedOperations = abortActiveOperations(expirationTime); LOGGER.info(CleanUpJob.LOG_MARKER, format(Messages.ABORTED_OPERATIONS_0, abortedOperations)); int deletedOperations = operationService.createQuery() .startedBefore(expirationTime) .inFinalState() .delete(); LOGGER.info(CleanUpJob.LOG_MARKER, format(Messages.DELETED_OPERATIONS_0, deletedOperations)); } @Inject  OperationsCleaner(OperationService operationService, ProcessActionRegistry processActionRegistry); }
OperationsCleaner implements Cleaner { @Override public void execute(Date expirationTime) { LOGGER.debug(CleanUpJob.LOG_MARKER, format(Messages.DELETING_OPERATIONS_STARTED_BEFORE_0, expirationTime)); int abortedOperations = abortActiveOperations(expirationTime); LOGGER.info(CleanUpJob.LOG_MARKER, format(Messages.ABORTED_OPERATIONS_0, abortedOperations)); int deletedOperations = operationService.createQuery() .startedBefore(expirationTime) .inFinalState() .delete(); LOGGER.info(CleanUpJob.LOG_MARKER, format(Messages.DELETED_OPERATIONS_0, deletedOperations)); } @Inject  OperationsCleaner(OperationService operationService, ProcessActionRegistry processActionRegistry); OperationsCleaner withPageSize(int pageSize); @Override void execute(Date expirationTime); }
OperationsCleaner implements Cleaner { @Override public void execute(Date expirationTime) { LOGGER.debug(CleanUpJob.LOG_MARKER, format(Messages.DELETING_OPERATIONS_STARTED_BEFORE_0, expirationTime)); int abortedOperations = abortActiveOperations(expirationTime); LOGGER.info(CleanUpJob.LOG_MARKER, format(Messages.ABORTED_OPERATIONS_0, abortedOperations)); int deletedOperations = operationService.createQuery() .startedBefore(expirationTime) .inFinalState() .delete(); LOGGER.info(CleanUpJob.LOG_MARKER, format(Messages.DELETED_OPERATIONS_0, deletedOperations)); } @Inject  OperationsCleaner(OperationService operationService, ProcessActionRegistry processActionRegistry); OperationsCleaner withPageSize(int pageSize); @Override void execute(Date expirationTime);  }