diff --git a/covid-19-service/build.gradle b/covid-19-service/build.gradle index 7604d38..ad7a5f2 100644 --- a/covid-19-service/build.gradle +++ b/covid-19-service/build.gradle @@ -45,9 +45,9 @@ dependencies { implementation group: 'org.jasypt', name: 'jasypt-hibernate4', version: '1.9.3' // SPRING BOOT AND BATCH - implementation 'org.springframework.boot:spring-boot-starter-web' - implementation 'org.springframework.boot:spring-boot-starter-batch' - implementation 'org.springframework.boot:spring-boot-starter-amqp' + implementation 'org.springframework.boot:spring-boot-starter-web:2.2.6.RELEASE' + implementation 'org.springframework.boot:spring-boot-starter-batch:2.2.6.RELEASE' + implementation 'org.springframework.boot:spring-boot-starter-amqp:2.2.6.RELEASE' // CLOUD implementation 'com.amazonaws:aws-java-sdk-s3:1.11.699' diff --git a/covid-19-service/src/main/java/com/ossez/covid19/service/batch/jobs/CloudJobConf.java b/covid-19-service/src/main/java/com/ossez/covid19/service/batch/jobs/CloudJobConf.java index 8240d48..533cecb 100644 --- a/covid-19-service/src/main/java/com/ossez/covid19/service/batch/jobs/CloudJobConf.java +++ b/covid-19-service/src/main/java/com/ossez/covid19/service/batch/jobs/CloudJobConf.java @@ -1,10 +1,12 @@ package com.ossez.covid19.service.batch.jobs; -import com.ossez.covid19.service.batch.tasklet.AwsTasklet; import com.ossez.covid19.common.models.Listing; -import com.ossez.covid19.service.batch.JobCompletionNotificationListener; +import com.ossez.covid19.service.batch.jobs.listener.JobCompletionNotificationListener; +import com.ossez.covid19.service.batch.tasklet.AwsTasklet; import org.springframework.batch.core.Job; import org.springframework.batch.core.Step; + +import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing; import org.springframework.batch.core.configuration.annotation.JobBuilderFactory; import org.springframework.batch.core.configuration.annotation.StepBuilderFactory; import org.springframework.batch.core.launch.support.RunIdIncrementer; @@ -13,23 +15,30 @@ import org.springframework.batch.item.ItemReader; import org.springframework.batch.item.ItemWriter; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.core.io.FileSystemResource; @Configuration +@ComponentScan +@EnableBatchProcessing public class CloudJobConf { - @Autowired - public JobBuilderFactory jobBuilderFactory; - @Autowired + public JobBuilderFactory jobBuilderFactory; public StepBuilderFactory stepBuilderFactory; + @Autowired + public CloudJobConf(JobBuilderFactory jobBuilderFactory, StepBuilderFactory stepBuilderFactory) { + this.jobBuilderFactory = jobBuilderFactory; + this.stepBuilderFactory = stepBuilderFactory; + } + @Bean - public Job cloudClean(JobCompletionNotificationListener listener, Step stepAws, Step deleteFilesStep) { + public Job cloudClean(JobCompletionNotificationListener listener, Step deleteFilesStep) { return jobBuilderFactory.get("cloudClean") .incrementer(new RunIdIncrementer()) .listener(listener) - .flow(stepAws).next(deleteFilesStep) + .flow(deleteFilesStep) .end() .build(); } diff --git a/covid-19-service/src/main/java/com/ossez/covid19/service/batch/JobCompletionNotificationListener.java b/covid-19-service/src/main/java/com/ossez/covid19/service/batch/jobs/listener/JobCompletionNotificationListener.java similarity index 94% rename from covid-19-service/src/main/java/com/ossez/covid19/service/batch/JobCompletionNotificationListener.java rename to covid-19-service/src/main/java/com/ossez/covid19/service/batch/jobs/listener/JobCompletionNotificationListener.java index 0ccff6e..e4d62b7 100644 --- a/covid-19-service/src/main/java/com/ossez/covid19/service/batch/JobCompletionNotificationListener.java +++ b/covid-19-service/src/main/java/com/ossez/covid19/service/batch/jobs/listener/JobCompletionNotificationListener.java @@ -1,4 +1,4 @@ -package com.ossez.covid19.service.batch; +package com.ossez.covid19.service.batch.jobs.listener; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/covid-19-service/src/main/java/com/ossez/covid19/service/batch/steps/LineProcessor.java b/covid-19-service/src/main/java/com/ossez/covid19/service/batch/steps/LineProcessor.java index 5d6052c..50cbad6 100644 --- a/covid-19-service/src/main/java/com/ossez/covid19/service/batch/steps/LineProcessor.java +++ b/covid-19-service/src/main/java/com/ossez/covid19/service/batch/steps/LineProcessor.java @@ -7,7 +7,9 @@ import org.springframework.batch.core.ExitStatus; import org.springframework.batch.core.StepExecution; import org.springframework.batch.core.StepExecutionListener; import org.springframework.batch.item.ItemProcessor; +import org.springframework.stereotype.Component; +@Component public final class LineProcessor implements ItemProcessor