@Override @Transactional public void writeItems(List<Object> items) throws Exception { try (PrintWriter archive = new PrintWriter( new BufferedWriter( new FileWriter( new File( jobContext.getProperties().getProperty(ARCHIVE_DIRECTORY) + "/archive_" + jobContext.getJobName() + "_" + jobContext.getInstanceId() + ".csv"), true)))) { for (Object item : items) { HandlingEventRegistrationAttempt attempt = (HandlingEventRegistrationAttempt) item; applicationEvents.receivedHandlingEventRegistrationAttempt(attempt); archive.println( attempt.getRegistrationTime() + "," + attempt.getCompletionTime() + "," + attempt.getTrackingId() + "," + attempt.getVoyageNumber() + "," + attempt.getUnLocode() + "," + attempt.getType()); } } }