├── .editorconfig ├── .github ├── dco.yml └── workflows │ ├── ci-maven-main.yml │ └── deploy-docs.yml ├── .gitignore ├── .mvn ├── jvm.config ├── maven.config └── wrapper │ ├── maven-wrapper.jar │ └── maven-wrapper.properties ├── .settings.xml ├── .springformat ├── CONTRIBUTING.adoc ├── LICENSE ├── README.adoc ├── docs ├── antora-playbook.yml ├── antora.yml ├── modules │ └── ROOT │ │ ├── assets │ │ └── images │ │ │ └── task_schema.png │ │ ├── nav.adoc │ │ ├── pages │ │ ├── _attributes.adoc │ │ ├── appendix-building-the-documentation.adoc │ │ ├── appendix-task-repository-schema.adoc │ │ ├── appendix.adoc │ │ ├── batch-starter.adoc │ │ ├── batch.adoc │ │ ├── configprops.adoc │ │ ├── features.adoc │ │ ├── getting-started.adoc │ │ ├── index.adoc │ │ ├── observability.adoc │ │ ├── preface.adoc │ │ └── stream.adoc │ │ └── partials │ │ ├── _configprops.adoc │ │ ├── _conventions.adoc │ │ ├── _metrics.adoc │ │ └── _spans.adoc ├── package.json ├── pom.xml └── src │ └── main │ ├── antora │ └── resources │ │ └── antora-resources │ │ └── antora.yml │ ├── asciidoc │ ├── .gitignore │ ├── Guardfile │ ├── README.adoc │ ├── images │ │ └── task_schema.png │ ├── index.htmladoc │ ├── index.htmlsingleadoc │ ├── index.pdfadoc │ ├── sagan-index.adoc │ ├── spring-cloud-task.epubadoc │ ├── spring-cloud-task.htmlsingleadoc │ └── spring-cloud-task.pdfadoc │ └── javadoc │ └── spring-javadoc.css ├── mvnw ├── mvnw.cmd ├── pom.xml ├── spring-cloud-starter-single-step-batch-job ├── pom.xml └── src │ ├── main │ ├── java │ │ └── org │ │ │ └── springframework │ │ │ └── cloud │ │ │ └── task │ │ │ └── batch │ │ │ └── autoconfigure │ │ │ ├── RangeConverter.java │ │ │ ├── SingleStepJobAutoConfiguration.java │ │ │ ├── SingleStepJobProperties.java │ │ │ ├── flatfile │ │ │ ├── FlatFileItemReaderAutoConfiguration.java │ │ │ ├── FlatFileItemReaderProperties.java │ │ │ ├── FlatFileItemWriterAutoConfiguration.java │ │ │ └── FlatFileItemWriterProperties.java │ │ │ ├── jdbc │ │ │ ├── JDBCSingleStepDataSourceAutoConfiguration.java │ │ │ ├── JdbcBatchItemWriterAutoConfiguration.java │ │ │ ├── JdbcBatchItemWriterProperties.java │ │ │ ├── JdbcCursorItemReaderAutoConfiguration.java │ │ │ └── JdbcCursorItemReaderProperties.java │ │ │ ├── kafka │ │ │ ├── KafkaItemReaderAutoConfiguration.java │ │ │ ├── KafkaItemReaderProperties.java │ │ │ ├── KafkaItemWriterAutoConfiguration.java │ │ │ └── KafkaItemWriterProperties.java │ │ │ └── rabbit │ │ │ ├── AmqpItemReaderAutoConfiguration.java │ │ │ ├── AmqpItemReaderProperties.java │ │ │ ├── AmqpItemWriterAutoConfiguration.java │ │ │ └── AmqpItemWriterProperties.java │ └── resources │ │ └── META-INF │ │ ├── spring-configuration-metadata.json │ │ └── spring │ │ └── org.springframework.boot.autoconfigure.AutoConfiguration.imports │ └── test │ ├── java │ └── org │ │ └── springframework │ │ └── cloud │ │ └── task │ │ └── batch │ │ └── autoconfigure │ │ ├── RangeConverterTests.java │ │ ├── SingleStepJobAutoConfigurationTests.java │ │ ├── flatfile │ │ ├── FlatFileItemReaderAutoConfigurationTests.java │ │ └── FlatFileItemWriterAutoConfigurationTests.java │ │ ├── jdbc │ │ ├── JdbcBatchItemWriterAutoConfigurationTests.java │ │ └── JdbcCursorItemReaderAutoConfigurationTests.java │ │ ├── kafka │ │ ├── KafkaItemReaderAutoConfigurationTests.java │ │ └── KafkaItemWriterTests.java │ │ └── rabbit │ │ ├── AmqpItemReaderAutoConfigurationTests.java │ │ └── AmqpItemWriterAutoConfigurationTests.java │ └── resources │ ├── logback-test.xml │ ├── schema-h2.sql │ ├── test.txt │ ├── testUTF16.csv │ ├── testUTF8.csv │ └── writerTestUTF16.txt ├── spring-cloud-starter-task └── pom.xml ├── spring-cloud-task-batch ├── pom.xml └── src │ ├── main │ ├── java │ │ └── org │ │ │ └── springframework │ │ │ └── cloud │ │ │ └── task │ │ │ └── batch │ │ │ ├── configuration │ │ │ ├── JobLaunchCondition.java │ │ │ ├── TaskBatchAutoConfiguration.java │ │ │ ├── TaskBatchExecutionListenerBeanPostProcessor.java │ │ │ ├── TaskBatchExecutionListenerFactoryBean.java │ │ │ ├── TaskBatchProperties.java │ │ │ ├── TaskJobLauncherApplicationRunnerFactoryBean.java │ │ │ └── TaskJobLauncherAutoConfiguration.java │ │ │ ├── handler │ │ │ └── TaskJobLauncherApplicationRunner.java │ │ │ ├── listener │ │ │ ├── TaskBatchDao.java │ │ │ ├── TaskBatchExecutionListener.java │ │ │ └── support │ │ │ │ ├── JdbcTaskBatchDao.java │ │ │ │ └── MapTaskBatchDao.java │ │ │ └── partition │ │ │ ├── CommandLineArgsProvider.java │ │ │ ├── DeployerPartitionHandler.java │ │ │ ├── DeployerStepExecutionHandler.java │ │ │ ├── EnvironmentVariablesProvider.java │ │ │ ├── NoOpEnvironmentVariablesProvider.java │ │ │ ├── PassThroughCommandLineArgsProvider.java │ │ │ ├── SimpleCommandLineArgsProvider.java │ │ │ ├── SimpleEnvironmentVariablesProvider.java │ │ │ └── TaskLauncherHandler.java │ └── resources │ │ └── META-INF │ │ ├── additional-spring-configuration-metadata.json │ │ └── spring │ │ └── org.springframework.boot.autoconfigure.AutoConfiguration.imports │ └── test │ ├── java │ └── org │ │ └── springframework │ │ └── cloud │ │ └── task │ │ └── batch │ │ ├── configuration │ │ ├── TaskBatchTest.java │ │ └── TaskJobLauncherAutoConfigurationTests.java │ │ ├── handler │ │ ├── TaskJobLauncherApplicationRunnerCoreTests.java │ │ └── TaskJobLauncherApplicationRunnerTests.java │ │ ├── listener │ │ ├── PrefixTests.java │ │ ├── PrimaryKeyTests.java │ │ └── TaskBatchExecutionListenerTests.java │ │ └── partition │ │ ├── DeployerPartitionHandlerTests.java │ │ ├── DeployerStepExecutionHandlerTests.java │ │ ├── NoOpEnvironmentVariablesProviderTests.java │ │ ├── PassThroughCommandLineArgsProviderTests.java │ │ └── SimpleCommandLineArgsProviderTests.java │ └── resources │ ├── META-INF │ └── spring │ │ └── org.springframework.cloud.task.batch.configuration.TaskBatchTest.imports │ ├── schema-h2.sql │ └── schema-with-primary-keys-h2.sql ├── spring-cloud-task-core ├── pom.xml └── src │ ├── main │ ├── java │ │ └── org │ │ │ └── springframework │ │ │ └── cloud │ │ │ └── task │ │ │ ├── configuration │ │ │ ├── DefaultTaskConfigurer.java │ │ │ ├── EnableTask.java │ │ │ ├── NoTransactionManagerProperty.java │ │ │ ├── SimpleTaskAutoConfiguration.java │ │ │ ├── SingleInstanceTaskListener.java │ │ │ ├── SingleTaskConfiguration.java │ │ │ ├── TaskConfigurer.java │ │ │ ├── TaskLifecycleConfiguration.java │ │ │ ├── TaskObservationCloudKeyValues.java │ │ │ ├── TaskProperties.java │ │ │ ├── TaskRepositoryDatabaseInitializerDetector.java │ │ │ ├── TaskRepositoryDependsOnDatabaseInitializationDetector.java │ │ │ ├── TaskRuntimeHints.java │ │ │ ├── observation │ │ │ │ ├── DefaultTaskObservationConvention.java │ │ │ │ ├── ObservationApplicationRunner.java │ │ │ │ ├── ObservationApplicationRunnerBeanPostProcessor.java │ │ │ │ ├── ObservationCommandLineRunner.java │ │ │ │ ├── ObservationCommandLineRunnerBeanPostProcessor.java │ │ │ │ ├── ObservationTaskAutoConfiguration.java │ │ │ │ ├── TaskDocumentedObservation.java │ │ │ │ ├── TaskObservationContext.java │ │ │ │ └── TaskObservationConvention.java │ │ │ └── package-info.java │ │ │ ├── listener │ │ │ ├── DefaultTaskExecutionObservationConvention.java │ │ │ ├── TaskException.java │ │ │ ├── TaskExecutionException.java │ │ │ ├── TaskExecutionListener.java │ │ │ ├── TaskExecutionListenerSupport.java │ │ │ ├── TaskExecutionObservation.java │ │ │ ├── TaskExecutionObservationContext.java │ │ │ ├── TaskExecutionObservationConvention.java │ │ │ ├── TaskLifecycleListener.java │ │ │ ├── TaskListenerExecutorObjectFactory.java │ │ │ ├── TaskObservations.java │ │ │ └── annotation │ │ │ │ ├── AfterTask.java │ │ │ │ ├── BeforeTask.java │ │ │ │ ├── FailedTask.java │ │ │ │ └── TaskListenerExecutor.java │ │ │ ├── package-info.java │ │ │ └── repository │ │ │ ├── TaskExecution.java │ │ │ ├── TaskExplorer.java │ │ │ ├── TaskNameResolver.java │ │ │ ├── TaskRepository.java │ │ │ ├── dao │ │ │ ├── JdbcTaskExecutionDao.java │ │ │ ├── MapTaskExecutionDao.java │ │ │ ├── TaskExecutionDao.java │ │ │ └── package-info.java │ │ │ ├── database │ │ │ ├── PagingQueryProvider.java │ │ │ └── support │ │ │ │ ├── AbstractSqlPagingQueryProvider.java │ │ │ │ ├── Db2PagingQueryProvider.java │ │ │ │ ├── H2PagingQueryProvider.java │ │ │ │ ├── HsqlPagingQueryProvider.java │ │ │ │ ├── MariaDbPagingQueryProvider.java │ │ │ │ ├── MySqlPagingQueryProvider.java │ │ │ │ ├── OraclePagingQueryProvider.java │ │ │ │ ├── PostgresPagingQueryProvider.java │ │ │ │ ├── SqlPagingQueryProviderFactoryBean.java │ │ │ │ ├── SqlPagingQueryUtils.java │ │ │ │ └── SqlServerPagingQueryProvider.java │ │ │ └── support │ │ │ ├── DatabaseType.java │ │ │ ├── SimpleTaskExplorer.java │ │ │ ├── SimpleTaskNameResolver.java │ │ │ ├── SimpleTaskRepository.java │ │ │ ├── TaskExecutionDaoFactoryBean.java │ │ │ ├── TaskRepositoryInitializer.java │ │ │ └── package-info.java │ └── resources │ │ ├── META-INF │ │ ├── additional-spring-configuration-metadata.json │ │ ├── spring.factories │ │ └── spring │ │ │ ├── aot.factories │ │ │ └── org.springframework.boot.autoconfigure.AutoConfiguration.imports │ │ └── org │ │ └── springframework │ │ └── cloud │ │ └── task │ │ ├── migration │ │ ├── 1.1.x │ │ │ ├── migration-h2.sql │ │ │ ├── migration-hsqldb.sql │ │ │ ├── migration-mysql.sql │ │ │ ├── migration-oracle.sql │ │ │ ├── migration-postgresql.sql │ │ │ └── migration-sqlserver.sql │ │ ├── 1.2.x │ │ │ ├── migration-db2.sql │ │ │ ├── migration-h2.sql │ │ │ ├── migration-hsqldb.sql │ │ │ ├── migration-mysql.sql │ │ │ ├── migration-oracle.sql │ │ │ ├── migration-postgresql.sql │ │ │ └── migration-sqlserver.sql │ │ ├── 2.2.x │ │ │ └── migration-oracle.sql │ │ └── 3.0.x │ │ │ ├── migration-db2.sql │ │ │ ├── migration-h2.sql │ │ │ ├── migration-hsqldb.sql │ │ │ ├── migration-mysql.sql │ │ │ └── migration-oracle.sql │ │ ├── schema-db2.sql │ │ ├── schema-h2.sql │ │ ├── schema-hsqldb.sql │ │ ├── schema-mariadb.sql │ │ ├── schema-mysql.sql │ │ ├── schema-oracle.sql │ │ ├── schema-postgresql.sql │ │ └── schema-sqlserver.sql │ └── test │ ├── java │ └── org │ │ └── springframework │ │ └── cloud │ │ └── task │ │ ├── SimpleSingleTaskAutoConfigurationTests.java │ │ ├── SimpleSingleTaskAutoConfigurationWithDataSourceTests.java │ │ ├── SimpleTaskAutoConfigurationTests.java │ │ ├── TaskCoreTests.java │ │ ├── TaskRepositoryInitializerDefaultTaskConfigurerTests.java │ │ ├── TaskRepositoryInitializerNoDataSourceTaskConfigurerTests.java │ │ ├── configuration │ │ ├── DefaultTaskConfigurerTests.java │ │ ├── RepositoryTransactionManagerConfigurationTests.java │ │ ├── TaskPropertiesTests.java │ │ ├── TestConfiguration.java │ │ └── observation │ │ │ └── ObservationIntegrationTests.java │ │ ├── listener │ │ ├── TaskExceptionTests.java │ │ ├── TaskExecutionListenerTests.java │ │ ├── TaskLifecycleListenerTests.java │ │ └── TaskListenerExecutorObjectFactoryTests.java │ │ ├── micrometer │ │ └── TaskObservationsTests.java │ │ ├── repository │ │ ├── H2TaskRepositoryIntegrationTests.java │ │ ├── MariaDbTaskRepositoryIntegrationTests.java │ │ ├── dao │ │ │ ├── BaseTaskExecutionDaoTestCases.java │ │ │ ├── JdbcTaskExecutionDaoMariaDBIntegrationTests.java │ │ │ └── TaskExecutionDaoTests.java │ │ ├── database │ │ │ └── support │ │ │ │ ├── FindAllPagingQueryProviderTests.java │ │ │ │ ├── H2PagingQueryProviderTests.java │ │ │ │ ├── InvalidPagingQueryProviderTests.java │ │ │ │ ├── SqlPagingQueryProviderFactoryBeanTests.java │ │ │ │ └── WhereClausePagingQueryProviderTests.java │ │ └── support │ │ │ ├── DatabaseTypeTests.java │ │ │ ├── SimpleTaskExplorerTests.java │ │ │ ├── SimpleTaskNameResolverTests.java │ │ │ ├── SimpleTaskRepositoryJdbcTests.java │ │ │ ├── SimpleTaskRepositoryMapTests.java │ │ │ ├── TaskDatabaseInitializerTests.java │ │ │ └── TaskExecutionDaoFactoryBeanTests.java │ │ └── util │ │ ├── TaskExecutionCreator.java │ │ ├── TestDBUtils.java │ │ ├── TestDefaultConfiguration.java │ │ ├── TestListener.java │ │ └── TestVerifierUtils.java │ └── resources │ ├── application.properties │ └── micrometer │ └── pcf-scs-info.json ├── spring-cloud-task-dependencies └── pom.xml ├── spring-cloud-task-integration-tests ├── pom.xml └── src │ └── test │ ├── java │ ├── configuration │ │ ├── JobConfiguration.java │ │ ├── JobSkipConfiguration.java │ │ ├── SkipItemReader.java │ │ └── SkipItemWriter.java │ └── org │ │ └── springframework │ │ └── cloud │ │ └── task │ │ ├── executionid │ │ ├── TaskStartApplication.java │ │ └── TaskStartTests.java │ │ ├── initializer │ │ └── TaskInitializerTests.java │ │ ├── launcher │ │ ├── TaskLauncherSinkTests.java │ │ └── app │ │ │ └── TaskLauncherSinkApplication.java │ │ └── listener │ │ ├── BatchExecutionEventTests.java │ │ └── TaskEventTests.java │ └── resources │ ├── application.properties │ └── org │ └── springframework │ └── cloud │ └── task │ └── listener │ ├── chunk-events-sink-channel.properties │ ├── item-process-sink-channel.properties │ ├── item-read-events-sink-channel.properties │ ├── item-write-events-sink-channel.properties │ ├── job-execution-sink-channel.properties │ ├── sink-channel.properties │ ├── skip-events-sink-channel.properties │ └── step-execution-sink-channel.properties ├── spring-cloud-task-samples ├── batch-events │ ├── .mvn │ │ └── wrapper │ │ │ ├── maven-wrapper.jar │ │ │ └── maven-wrapper.properties │ ├── README.adoc │ ├── mvnw │ ├── mvnw.cmd │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── io │ │ │ │ └── spring │ │ │ │ └── cloud │ │ │ │ └── BatchEventsApplication.java │ │ └── resources │ │ │ ├── application.properties │ │ │ └── logback-test.xml │ │ └── test │ │ ├── java │ │ └── io │ │ │ └── spring │ │ │ └── cloud │ │ │ └── BatchEventsApplicationTests.java │ │ └── resources │ │ └── io │ │ └── spring │ │ └── task │ │ └── listener │ │ └── job-listener-sink-channel.properties ├── batch-job │ ├── .mvn │ │ └── wrapper │ │ │ ├── maven-wrapper.jar │ │ │ └── maven-wrapper.properties │ ├── README.adoc │ ├── mvnw │ ├── mvnw.cmd │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── io │ │ │ │ └── spring │ │ │ │ ├── BatchJobApplication.java │ │ │ │ └── configuration │ │ │ │ └── JobConfiguration.java │ │ └── resources │ │ │ └── application.properties │ │ └── test │ │ ├── java │ │ └── io │ │ │ └── spring │ │ │ ├── BatchJobApplicationTests.java │ │ │ ├── BatchJobTestConfiguration.java │ │ │ └── TestBatchJobApp.java │ │ └── resources │ │ └── application.properties ├── jpa-sample │ ├── .mvn │ │ └── wrapper │ │ │ ├── maven-wrapper.jar │ │ │ └── maven-wrapper.properties │ ├── README.adoc │ ├── mvnw │ ├── mvnw.cmd │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── io │ │ │ │ └── spring │ │ │ │ ├── JpaApplication.java │ │ │ │ └── configuration │ │ │ │ ├── TaskRunComponent.java │ │ │ │ ├── TaskRunOutput.java │ │ │ │ └── TaskRunRepository.java │ │ └── resources │ │ │ ├── application-cloud.yml │ │ │ └── application.yml │ │ └── test │ │ ├── java │ │ └── io │ │ │ └── spring │ │ │ └── JpaApplicationTests.java │ │ └── resources │ │ └── application.properties ├── multiple-datasources │ ├── .mvn │ │ └── wrapper │ │ │ ├── maven-wrapper.jar │ │ │ └── maven-wrapper.properties │ ├── README.adoc │ ├── mvnw │ ├── mvnw.cmd │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── io │ │ │ │ └── spring │ │ │ │ ├── MultipleDataSourcesApplication.java │ │ │ │ ├── configuration │ │ │ │ ├── CustomTaskConfigurer.java │ │ │ │ ├── EmbeddedDataSourceConfiguration.java │ │ │ │ └── ExternalDataSourceConfiguration.java │ │ │ │ └── task │ │ │ │ └── SampleCommandLineRunner.java │ │ └── resources │ │ │ └── application.properties │ │ └── test │ │ ├── java │ │ └── io │ │ │ └── spring │ │ │ ├── MultiDataSourcesApplicationTests.java │ │ │ └── MultiDataSourcesExternalApplicationTests.java │ │ └── resources │ │ └── application.properties ├── partitioned-batch-job │ ├── .mvn │ │ └── wrapper │ │ │ ├── maven-wrapper.jar │ │ │ └── maven-wrapper.properties │ ├── README.adoc │ ├── mvnw │ ├── mvnw.cmd │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── io │ │ │ │ └── spring │ │ │ │ ├── JobConfiguration.java │ │ │ │ └── PartitionedBatchJobApplication.java │ │ └── resources │ │ │ └── application.properties │ │ └── test │ │ └── java │ │ └── org │ │ └── springframework │ │ └── cloud │ │ └── task │ │ └── partitioner │ │ └── TaskPartitionerTests.java ├── pom.xml ├── single-step-batch-job │ ├── .mvn │ │ └── wrapper │ │ │ ├── maven-wrapper.jar │ │ │ └── maven-wrapper.properties │ ├── README.adoc │ ├── mvnw │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── io │ │ │ │ └── spring │ │ │ │ └── SingleStepBatchJobApplication.java │ │ └── resources │ │ │ ├── application-amqpreader.properties │ │ │ ├── application-amqpwriter.properties │ │ │ ├── application-ffreader.properties │ │ │ ├── application-ffwriter.properties │ │ │ ├── application-jdbcreader.properties │ │ │ ├── application-jdbcwriter.properties │ │ │ ├── application-kafkareader.properties │ │ │ ├── application-kafkawriter.properties │ │ │ ├── application.properties │ │ │ └── test.txt │ │ └── test │ │ ├── java │ │ └── io │ │ │ └── spring │ │ │ └── BatchJobApplicationTests.java │ │ └── resources │ │ ├── schema-h2.sql │ │ ├── test.txt │ │ └── testresult.txt ├── task-events │ ├── .mvn │ │ └── wrapper │ │ │ ├── maven-wrapper.jar │ │ │ └── maven-wrapper.properties │ ├── README.adoc │ ├── mvnw │ ├── mvnw.cmd │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── io │ │ │ └── spring │ │ │ └── TaskEventsApplication.java │ │ └── resources │ │ └── application.properties ├── task-observations │ ├── .gitignore │ ├── .mvn │ │ └── wrapper │ │ │ ├── maven-wrapper.jar │ │ │ └── maven-wrapper.properties │ ├── README.adoc │ ├── mvnw │ ├── mvnw.cmd │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── io │ │ │ │ └── spring │ │ │ │ └── taskobservations │ │ │ │ ├── ObservationConfiguration.java │ │ │ │ └── TaskObservationsApplication.java │ │ └── resources │ │ │ └── application.properties │ │ └── test │ │ └── java │ │ └── io │ │ └── spring │ │ └── taskobservations │ │ └── TaskObservationsApplicationTests.java ├── taskprocessor │ ├── .mvn │ │ └── wrapper │ │ │ ├── maven-wrapper.jar │ │ │ └── maven-wrapper.properties │ ├── README.adoc │ ├── mvnw │ ├── mvnw.cmd │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── io │ │ │ │ └── spring │ │ │ │ ├── TaskProcessor.java │ │ │ │ ├── TaskProcessorApplication.java │ │ │ │ └── TaskProcessorProperties.java │ │ └── resources │ │ │ └── application.properties │ │ └── test │ │ └── java │ │ └── io │ │ └── spring │ │ └── TaskProcessorApplicationTests.java ├── tasksink │ ├── .mvn │ │ └── wrapper │ │ │ ├── maven-wrapper.jar │ │ │ └── maven-wrapper.properties │ ├── README.adoc │ ├── mvnw │ ├── mvnw.cmd │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── io │ │ │ │ └── spring │ │ │ │ └── TaskSinkApplication.java │ │ └── resources │ │ │ └── application.properties │ │ └── test │ │ ├── java │ │ └── io │ │ │ └── spring │ │ │ ├── TaskSinkApplicationTests.java │ │ │ └── configuration │ │ │ └── TaskSinkConfiguration.java │ │ └── resources │ │ └── application.properties └── timestamp │ ├── README.adoc │ ├── pom.xml │ └── src │ ├── main │ ├── java │ │ └── org │ │ │ └── springframework │ │ │ └── cloud │ │ │ └── task │ │ │ └── timestamp │ │ │ ├── TaskApplication.java │ │ │ └── TimestampTaskProperties.java │ └── resources │ │ └── application.properties │ └── test │ ├── java │ └── org │ │ └── springframework │ │ └── cloud │ │ └── task │ │ └── timestamp │ │ ├── TaskApplicationTests.java │ │ └── TimestampTaskPropertiesTests.java │ └── resources │ └── application.properties ├── spring-cloud-task-stream ├── .mvn │ └── wrapper │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── pom.xml └── src │ ├── main │ ├── java │ │ └── org │ │ │ └── springframework │ │ │ └── cloud │ │ │ └── task │ │ │ ├── batch │ │ │ └── listener │ │ │ │ ├── BatchEventAutoConfiguration.java │ │ │ │ ├── EventEmittingChunkListener.java │ │ │ │ ├── EventEmittingItemProcessListener.java │ │ │ │ ├── EventEmittingItemReadListener.java │ │ │ │ ├── EventEmittingItemWriteListener.java │ │ │ │ ├── EventEmittingJobExecutionListener.java │ │ │ │ ├── EventEmittingSkipListener.java │ │ │ │ ├── EventEmittingStepExecutionListener.java │ │ │ │ └── support │ │ │ │ ├── BatchJobHeaders.java │ │ │ │ ├── ExitStatus.java │ │ │ │ ├── JobExecutionEvent.java │ │ │ │ ├── JobInstanceEvent.java │ │ │ │ ├── JobParameterEvent.java │ │ │ │ ├── JobParametersEvent.java │ │ │ │ ├── MessagePublisher.java │ │ │ │ ├── StepExecutionEvent.java │ │ │ │ ├── TaskBatchEventListenerBeanPostProcessor.java │ │ │ │ └── TaskEventProperties.java │ │ │ ├── launcher │ │ │ ├── TaskLaunchRequest.java │ │ │ ├── TaskLauncherSink.java │ │ │ └── annotation │ │ │ │ └── EnableTaskLauncher.java │ │ │ └── listener │ │ │ └── TaskEventAutoConfiguration.java │ └── resources │ │ ├── META-INF │ │ ├── additional-spring-configuration-metadata.json │ │ └── spring │ │ │ └── org.springframework.boot.autoconfigure.AutoConfiguration.imports │ │ └── org │ │ └── springframework │ │ └── cloud │ │ └── task │ │ └── application.properties │ └── test │ ├── java │ └── org │ │ └── springframework │ │ └── cloud │ │ └── task │ │ ├── batch │ │ └── listener │ │ │ ├── EventListenerTests.java │ │ │ ├── JobExecutionEventTests.java │ │ │ ├── JobInstanceEventTests.java │ │ │ ├── JobParameterEventTests.java │ │ │ ├── JobParametersEventTests.java │ │ │ ├── StepExecutionEventTests.java │ │ │ ├── TaskBatchEventListenerBeanPostProcessorTests.java │ │ │ └── support │ │ │ └── TaskBatchEventListenerBeanPostProcessorRuntimeHintTests.java │ │ ├── launcher │ │ ├── TaskLaunchConfigurationExistingTests.java │ │ ├── TaskLaunchRequestTests.java │ │ ├── TaskLauncherFunctionTests.java │ │ ├── app │ │ │ └── TaskLauncherSinkApplication.java │ │ └── configuration │ │ │ └── TaskConfiguration.java │ │ └── listener │ │ └── TaskEventTests.java │ └── resources │ └── application.properties └── src └── checkstyle └── checkstyle-suppressions.xml /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig is awesome: https://EditorConfig.org 2 | 3 | # top-most EditorConfig file 4 | root = true 5 | 6 | [*] 7 | indent_style = tab 8 | indent_size = 4 9 | end_of_line = lf 10 | insert_final_newline = true 11 | 12 | [*.yml] 13 | indent_style = space 14 | indent_size = 2 15 | -------------------------------------------------------------------------------- /.github/dco.yml: -------------------------------------------------------------------------------- 1 | require: 2 | members: false 3 | -------------------------------------------------------------------------------- /.github/workflows/ci-maven-main.yml: -------------------------------------------------------------------------------- 1 | name: CI PRs 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | pull_request: 8 | branches: 9 | - main 10 | 11 | jobs: 12 | build: 13 | runs-on: ubuntu-latest 14 | name: CI PR Build 15 | steps: 16 | - uses: actions/checkout@v2 17 | - uses: actions/setup-java@v2 18 | with: 19 | distribution: adopt 20 | java-version: 17 21 | - run: mvn "-Dmaven.repo.local=.m2" -U -B package -s .settings.xml 22 | -------------------------------------------------------------------------------- /.github/workflows/deploy-docs.yml: -------------------------------------------------------------------------------- 1 | name: Deploy Docs 2 | on: 3 | push: 4 | branches-ignore: [ gh-pages ] 5 | tags: '**' 6 | repository_dispatch: 7 | types: request-build-reference # legacy 8 | #schedule: 9 | #- cron: '0 10 * * *' # Once per day at 10am UTC 10 | workflow_dispatch: 11 | permissions: 12 | actions: write 13 | jobs: 14 | build: 15 | runs-on: ubuntu-latest 16 | # if: github.repository_owner == 'spring-cloud' 17 | steps: 18 | - name: Checkout 19 | uses: actions/checkout@v3 20 | with: 21 | ref: docs-build 22 | fetch-depth: 1 23 | - name: Dispatch (partial build) 24 | if: github.ref_type == 'branch' 25 | env: 26 | GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} 27 | run: gh workflow run deploy-docs.yml -r $(git rev-parse --abbrev-ref HEAD) -f build-refname=${{ github.ref_name }} 28 | - name: Dispatch (full build) 29 | if: github.ref_type == 'tag' 30 | env: 31 | GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} 32 | run: gh workflow run deploy-docs.yml -r $(git rev-parse --abbrev-ref HEAD) 33 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | .#* 3 | *# 4 | *.sw* 5 | _site/ 6 | .factorypath 7 | .gradletasknamecache 8 | .DS_Store 9 | /application.yml 10 | /application.properties 11 | asciidoctor.css 12 | atlassian-ide-plugin.xml 13 | bin/ 14 | build/ 15 | dump.rdb 16 | out 17 | spring-shell.log 18 | target/ 19 | test-output 20 | result.txt 21 | 22 | # Eclipse artifacts, including WTP generated manifests 23 | .classpath 24 | .project 25 | .settings/ 26 | .springBeans 27 | spring-*/src/main/java/META-INF/MANIFEST.MF 28 | 29 | # IDEA artifacts and output dirs 30 | *.iml 31 | *.ipr 32 | *.iws 33 | .idea/* 34 | 35 | # Github Actions 36 | .m2 37 | 38 | node 39 | node_modules 40 | build 41 | /package.json 42 | package-lock.json 43 | -------------------------------------------------------------------------------- /.mvn/jvm.config: -------------------------------------------------------------------------------- 1 | -Xmx1024m -XX:CICompilerCount=1 -XX:TieredStopAtLevel=1 -Djava.security.egd=file:/dev/./urandom 2 | -------------------------------------------------------------------------------- /.mvn/maven.config: -------------------------------------------------------------------------------- 1 | -DaltSnapshotDeploymentRepository=repo.spring.io::default::https://repo.spring.io/libs-snapshot-local 2 | -P spring 3 | -------------------------------------------------------------------------------- /.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spring-cloud/spring-cloud-task/b9dfa48bb3b4970f68008340a28d31dfb79b8ea5/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.1/apache-maven-3.9.1-bin.zip 18 | wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar 19 | -------------------------------------------------------------------------------- /.springformat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spring-cloud/spring-cloud-task/b9dfa48bb3b4970f68008340a28d31dfb79b8ea5/.springformat -------------------------------------------------------------------------------- /README.adoc: -------------------------------------------------------------------------------- 1 | //// 2 | DO NOT EDIT THIS FILE. IT WAS GENERATED. 3 | Manual changes to this file will be lost when it is generated again. 4 | Edit the files in the src/main/asciidoc/ directory instead. 5 | //// 6 | 7 | 8 | [[spring-cloud-task]] 9 | = Spring Cloud Task 10 | 11 | Is a project centered around the idea of processing on demand. A user is able to develop 12 | a “task” that can be deployed, executed and removed on demand, yet the result of the 13 | process persists beyond the life of the task for future reporting. 14 | 15 | 16 | [[requirements:]] 17 | == Requirements: 18 | 19 | * Java 17 or Above 20 | 21 | [[build-main-project:]] 22 | == Build Main Project: 23 | 24 | [source,shell,indent=2] 25 | ---- 26 | $ ./mvnw clean install 27 | ---- 28 | 29 | [[example:]] 30 | == Example: 31 | 32 | [source,java,indent=2] 33 | ---- 34 | @SpringBootApplication 35 | @EnableTask 36 | public class MyApp { 37 | 38 | @Bean 39 | public MyTaskApplication myTask() { 40 | return new MyTaskApplication(); 41 | } 42 | 43 | public static void main(String[] args) { 44 | SpringApplication.run(MyApp.class); 45 | } 46 | 47 | public static class MyTaskApplication implements ApplicationRunner { 48 | 49 | @Override 50 | public void run(ApplicationArguments args) throws Exception { 51 | System.out.println("Hello World"); 52 | } 53 | } 54 | } 55 | ---- 56 | 57 | [[code-of-conduct]] 58 | == Code of Conduct 59 | This project adheres to the Contributor Covenant link:CODE_OF_CONDUCT.adoc[code of conduct]. By participating, you are expected to uphold this code. Please report unacceptable behavior to spring-code-of-conduct@pivotal.io. 60 | 61 | [[building-the-project]] 62 | == Building the Project 63 | 64 | This project requires that you invoke the Javadoc engine from the Maven command line. You can do so by appending `javadoc:aggregate` to the rest of your Maven command. 65 | For example, to build the entire project, you could use `mvn clean install -DskipTests -P docs`. 66 | -------------------------------------------------------------------------------- /docs/antora-playbook.yml: -------------------------------------------------------------------------------- 1 | antora: 2 | extensions: 3 | - require: '@springio/antora-extensions' 4 | root_component_name: 'cloud-task' 5 | site: 6 | title: Spring Cloud Task 7 | url: https://docs.spring.io/spring-cloud-task/reference/ 8 | content: 9 | sources: 10 | - url: ./.. 11 | branches: HEAD 12 | start_path: docs 13 | worktrees: true 14 | asciidoc: 15 | attributes: 16 | page-stackoverflow-url: https://stackoverflow.com/tags/spring-cloud-task 17 | page-pagination: '' 18 | hide-uri-scheme: '@' 19 | tabs-sync-option: '@' 20 | chomp: 'all' 21 | extensions: 22 | - '@asciidoctor/tabs' 23 | - '@springio/asciidoctor-extensions' 24 | sourcemap: true 25 | urls: 26 | latest_version_segment: '' 27 | runtime: 28 | log: 29 | failure_level: warn 30 | format: pretty 31 | ui: 32 | bundle: 33 | url: https://github.com/spring-io/antora-ui-spring/releases/download/v0.4.15/ui-bundle.zip 34 | -------------------------------------------------------------------------------- /docs/antora.yml: -------------------------------------------------------------------------------- 1 | name: cloud-task 2 | version: true 3 | title: spring-cloud-task 4 | nav: 5 | - modules/ROOT/nav.adoc 6 | ext: 7 | collector: 8 | run: 9 | command: ./mvnw --no-transfer-progress -B process-resources -Pdocs -pl docs -Dantora-maven-plugin.phase=none -Dgenerate-docs.phase=none -Dgenerate-readme.phase=none -Dgenerate-cloud-resources.phase=none -Dmaven-dependency-plugin-for-docs.phase=none -Dmaven-dependency-plugin-for-docs-classes.phase=none -DskipTests -DdisableConfigurationProperties 10 | local: true 11 | scan: 12 | dir: ./target/classes/antora-resources/ 13 | -------------------------------------------------------------------------------- /docs/modules/ROOT/assets/images/task_schema.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spring-cloud/spring-cloud-task/b9dfa48bb3b4970f68008340a28d31dfb79b8ea5/docs/modules/ROOT/assets/images/task_schema.png -------------------------------------------------------------------------------- /docs/modules/ROOT/nav.adoc: -------------------------------------------------------------------------------- 1 | * xref:index.adoc[Introduction] 2 | * xref:getting-started.adoc[] 3 | * xref:features.adoc[] 4 | * xref:batch.adoc[] 5 | * xref:batch-starter.adoc[] 6 | * xref:stream.adoc[] 7 | * xref:appendix.adoc[] 8 | ** xref:appendix-task-repository-schema.adoc[] 9 | ** xref:appendix-building-the-documentation.adoc[] 10 | ** xref:observability.adoc[] 11 | -------------------------------------------------------------------------------- /docs/modules/ROOT/pages/appendix-building-the-documentation.adoc: -------------------------------------------------------------------------------- 1 | 2 | [[appendix-building-the-documentation]] 3 | = Building This Documentation 4 | :page-section-summary-toc: 1 5 | 6 | This project uses Maven to generate this documentation. To generate it for yourself, 7 | run the following command: `$ mvn clean install -DskipTests -P docs`. 8 | -------------------------------------------------------------------------------- /docs/modules/ROOT/pages/appendix.adoc: -------------------------------------------------------------------------------- 1 | 2 | [[appendix]] 3 | = Appendices 4 | :page-section-summary-toc: 1 5 | 6 | 7 | 8 | ifndef::train-docs[] 9 | endif::[] 10 | 11 | -------------------------------------------------------------------------------- /docs/modules/ROOT/pages/configprops.adoc: -------------------------------------------------------------------------------- 1 | [[configuration-properties]] 2 | = Configuration Properties 3 | 4 | Below you can find a list of configuration properties. 5 | 6 | include::partial$_configprops.adoc[] 7 | -------------------------------------------------------------------------------- /docs/modules/ROOT/pages/index.adoc: -------------------------------------------------------------------------------- 1 | [[spring-cloud-task-reference-guide]] 2 | = Spring Cloud Task Reference Guide 3 | 4 | Michael Minella, Glenn Renfro, Jay Bryant 5 | 6 | :page-section-summary-toc: 1 7 | 8 | include::preface.adoc[leveloffset=1] 9 | 10 | // ====================================================================================== 11 | 12 | Version {project-version} 13 | 14 | (C) 2009-2022 VMware, Inc. All rights reserved. 15 | 16 | Copies of this document may be made for your own use and for distribution to 17 | others, provided that you do not charge any fee for such copies and further 18 | provided that each copy contains this Copyright Notice, whether distributed in 19 | print or electronically. 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | // ====================================================================================== 29 | -------------------------------------------------------------------------------- /docs/modules/ROOT/pages/observability.adoc: -------------------------------------------------------------------------------- 1 | [[observability]] 2 | = Observability 3 | 4 | == Observability metadata 5 | 6 | include::partial$_metrics.adoc[] 7 | 8 | include::partial$_spans.adoc[] 9 | -------------------------------------------------------------------------------- /docs/modules/ROOT/partials/_conventions.adoc: -------------------------------------------------------------------------------- 1 | [[observability-conventions]] 2 | === Observability - Conventions 3 | 4 | Below you can find a list of all `GlobalObservationConvention` and `ObservationConvention` declared by this project. 5 | 6 | .ObservationConvention implementations 7 | |=== 8 | |ObservationConvention Class Name | Applicable ObservationContext Class Name 9 | |`org.springframework.cloud.task.listener.DefaultTaskExecutionObservationConvention`|`TaskExecutionObservationContext` 10 | |`org.springframework.cloud.task.listener.TaskExecutionObservationConvention`|`TaskExecutionObservationContext` 11 | |`org.springframework.cloud.task.configuration.observation.DefaultTaskObservationConvention`|`TaskObservationContext` 12 | |`org.springframework.cloud.task.configuration.observation.TaskObservationConvention`|`TaskObservationContext` 13 | |=== 14 | -------------------------------------------------------------------------------- /docs/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "antora": "3.2.0-alpha.8", 4 | "@antora/atlas-extension": "1.0.0-alpha.2", 5 | "@antora/collector-extension": "1.0.1", 6 | "@asciidoctor/tabs": "1.0.0-beta.6", 7 | "@springio/antora-extensions": "1.14.2", 8 | "@springio/asciidoctor-extensions": "1.0.0-alpha.14" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /docs/src/main/antora/resources/antora-resources/antora.yml: -------------------------------------------------------------------------------- 1 | version: @antora-component.version@ 2 | prerelease: @antora-component.prerelease@ 3 | 4 | asciidoc: 5 | attributes: 6 | attribute-missing: 'warn' 7 | chomp: 'all' 8 | project-root: @maven.multiModuleProjectDirectory@ 9 | github-repo: @docs.main@ 10 | github-raw: https://raw.githubusercontent.com/spring-cloud/@docs.main@/@github-tag@ 11 | github-code: https://github.com/spring-cloud/@docs.main@/tree/@github-tag@ 12 | github-issues: https://github.com/spring-cloud/@docs.main@/issues/ 13 | github-wiki: https://github.com/spring-cloud/@docs.main@/wiki 14 | spring-cloud-version: @project.version@ 15 | github-tag: @github-tag@ 16 | version-type: @version-type@ 17 | docs-url: https://docs.spring.io/@docs.main@/docs/@project.version@ 18 | raw-docs-url: https://raw.githubusercontent.com/spring-cloud/@docs.main@/@github-tag@ 19 | project-version: @project.version@ 20 | project-name: @docs.main@ 21 | -------------------------------------------------------------------------------- /docs/src/main/asciidoc/.gitignore: -------------------------------------------------------------------------------- 1 | *.html 2 | *.css 3 | -------------------------------------------------------------------------------- /docs/src/main/asciidoc/Guardfile: -------------------------------------------------------------------------------- 1 | require 'asciidoctor' 2 | require 'erb' 3 | 4 | guard 'shell' do 5 | watch(/.*\.adoc$/) {|m| 6 | Asciidoctor.render_file('index.adoc', \ 7 | :in_place => true, \ 8 | :safe => Asciidoctor::SafeMode::UNSAFE, \ 9 | :attributes => {\ 10 | 'source-highlighter' => 'prettify', \ 11 | 'icons' => 'font', \ 12 | 'linkcss' => 'true', \ 13 | 'copycss' => 'true', \ 14 | 'doctype' => 'book'}) 15 | } 16 | end 17 | 18 | guard 'livereload' do 19 | watch(%r{^.+\.(css|js|html)$}) 20 | end 21 | -------------------------------------------------------------------------------- /docs/src/main/asciidoc/README.adoc: -------------------------------------------------------------------------------- 1 | [[spring-cloud-task]] 2 | = Spring Cloud Task 3 | 4 | Is a project centered around the idea of processing on demand. A user is able to develop 5 | a “task” that can be deployed, executed and removed on demand, yet the result of the 6 | process persists beyond the life of the task for future reporting. 7 | 8 | 9 | [[requirements:]] 10 | == Requirements: 11 | 12 | * Java 17 or Above 13 | 14 | [[build-main-project:]] 15 | == Build Main Project: 16 | 17 | [source,shell,indent=2] 18 | ---- 19 | $ ./mvnw clean install 20 | ---- 21 | 22 | [[example:]] 23 | == Example: 24 | 25 | [source,java,indent=2] 26 | ---- 27 | @SpringBootApplication 28 | @EnableTask 29 | public class MyApp { 30 | 31 | @Bean 32 | public MyTaskApplication myTask() { 33 | return new MyTaskApplication(); 34 | } 35 | 36 | public static void main(String[] args) { 37 | SpringApplication.run(MyApp.class); 38 | } 39 | 40 | public static class MyTaskApplication implements ApplicationRunner { 41 | 42 | @Override 43 | public void run(ApplicationArguments args) throws Exception { 44 | System.out.println("Hello World"); 45 | } 46 | } 47 | } 48 | ---- 49 | 50 | [[code-of-conduct]] 51 | == Code of Conduct 52 | This project adheres to the Contributor Covenant link:CODE_OF_CONDUCT.adoc[code of conduct]. By participating, you are expected to uphold this code. Please report unacceptable behavior to spring-code-of-conduct@pivotal.io. 53 | 54 | [[building-the-project]] 55 | == Building the Project 56 | 57 | This project requires that you invoke the Javadoc engine from the Maven command line. You can do so by appending `javadoc:aggregate` to the rest of your Maven command. 58 | For example, to build the entire project, you could use `mvn clean install -DskipTests -P docs`. 59 | -------------------------------------------------------------------------------- /docs/src/main/asciidoc/images/task_schema.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spring-cloud/spring-cloud-task/b9dfa48bb3b4970f68008340a28d31dfb79b8ea5/docs/src/main/asciidoc/images/task_schema.png -------------------------------------------------------------------------------- /docs/src/main/asciidoc/index.htmladoc: -------------------------------------------------------------------------------- 1 | include::spring-cloud-task.adoc[] 2 | -------------------------------------------------------------------------------- /docs/src/main/asciidoc/index.htmlsingleadoc: -------------------------------------------------------------------------------- 1 | = Spring Cloud Task Reference Guide 2 | Michael Minella, Glenn Renfro, Jay Bryant 3 | 4 | include::_attributes.adoc[] 5 | 6 | // ====================================================================================== 7 | 8 | (C) 2009-2020 VMware, Inc. All rights reserved. 9 | 10 | Copies of this document may be made for your own use and for distribution to 11 | others, provided that you do not charge any fee for such copies and further 12 | provided that each copy contains this Copyright Notice, whether distributed in 13 | print or electronically. 14 | 15 | include::preface.adoc[leveloffset=+1] 16 | 17 | include::getting-started.adoc[leveloffset=+1] 18 | 19 | include::features.adoc[leveloffset=+1] 20 | 21 | include::batch.adoc[leveloffset=+1] 22 | 23 | include::batch-starter.adoc[leveloffset=+1] 24 | 25 | include::stream.adoc[leveloffset=+1] 26 | 27 | include::appendix.adoc[leveloffset=+1] 28 | 29 | // ====================================================================================== 30 | -------------------------------------------------------------------------------- /docs/src/main/asciidoc/index.pdfadoc: -------------------------------------------------------------------------------- 1 | include::spring-cloud-task.pdfadoc[] 2 | -------------------------------------------------------------------------------- /docs/src/main/asciidoc/sagan-index.adoc: -------------------------------------------------------------------------------- 1 | Spring Cloud Task allows a user to develop and run short lived microservices using Spring Cloud and run them locally, in the cloud, even on Spring Cloud Data Flow. Just add `@EnableTask` and run your app as a Spring Boot app (single application context). 2 | If you are new to Spring Cloud Task, take a look at our https://docs.spring.io/spring-cloud-task/docs/2.0.0.RELEASE/reference/htmlsingle/#getting-started[Getting Started] docs. 3 | -------------------------------------------------------------------------------- /docs/src/main/asciidoc/spring-cloud-task.epubadoc: -------------------------------------------------------------------------------- 1 | = Spring Cloud Task Reference Guide 2 | Michael Minella, Glenn Renfro, Jay Bryant 3 | 4 | include::_attributes.adoc[] 5 | 6 | // ====================================================================================== 7 | 8 | (C) 2009-2022 VMware, Inc. All rights reserved. 9 | 10 | Copies of this document may be made for your own use and for distribution to 11 | others, provided that you do not charge any fee for such copies and further 12 | provided that each copy contains this Copyright Notice, whether distributed in 13 | print or electronically. 14 | 15 | include::preface.adoc[leveloffset=+1] 16 | 17 | include::getting-started.adoc[leveloffset=+1] 18 | 19 | include::features.adoc[leveloffset=+1] 20 | 21 | include::batch.adoc[leveloffset=+1] 22 | 23 | include::batch-starter.adoc[leveloffset=+1] 24 | 25 | include::stream.adoc[leveloffset=+1] 26 | 27 | include::appendix.adoc[leveloffset=+1] 28 | 29 | // ====================================================================================== 30 | -------------------------------------------------------------------------------- /docs/src/main/asciidoc/spring-cloud-task.htmlsingleadoc: -------------------------------------------------------------------------------- 1 | = Spring Cloud Task Reference Guide 2 | Michael Minella, Glenn Renfro, Jay Bryant 3 | 4 | include::_attributes.adoc[] 5 | 6 | // ====================================================================================== 7 | 8 | (C) 2009-2020 VMware, Inc. All rights reserved. 9 | 10 | Copies of this document may be made for your own use and for distribution to 11 | others, provided that you do not charge any fee for such copies and further 12 | provided that each copy contains this Copyright Notice, whether distributed in 13 | print or electronically. 14 | 15 | include::preface.adoc[leveloffset=+1] 16 | 17 | include::getting-started.adoc[leveloffset=+1] 18 | 19 | include::features.adoc[leveloffset=+1] 20 | 21 | include::batch.adoc[leveloffset=+1] 22 | 23 | include::batch-starter.adoc[leveloffset=+1] 24 | 25 | include::stream.adoc[leveloffset=+1] 26 | 27 | include::appendix.adoc[leveloffset=+1] 28 | 29 | // ====================================================================================== 30 | -------------------------------------------------------------------------------- /docs/src/main/asciidoc/spring-cloud-task.pdfadoc: -------------------------------------------------------------------------------- 1 | = Spring Cloud Task Reference Guide 2 | Michael Minella, Glenn Renfro, Jay Bryant 3 | 4 | include::_attributes.adoc[] 5 | 6 | // ====================================================================================== 7 | 8 | (C) 2009-2022 VMware, Inc. All rights reserved. 9 | 10 | Copies of this document may be made for your own use and for distribution to 11 | others, provided that you do not charge any fee for such copies and further 12 | provided that each copy contains this Copyright Notice, whether distributed in 13 | print or electronically. 14 | 15 | include::preface.adoc[leveloffset=+1] 16 | 17 | include::getting-started.adoc[leveloffset=+1] 18 | 19 | include::features.adoc[leveloffset=+1] 20 | 21 | include::batch.adoc[leveloffset=+1] 22 | 23 | include::batch-starter.adoc[leveloffset=+1] 24 | 25 | include::stream.adoc[leveloffset=+1] 26 | 27 | include::appendix.adoc[leveloffset=+1] 28 | 29 | // ====================================================================================== 30 | -------------------------------------------------------------------------------- /spring-cloud-starter-single-step-batch-job/src/main/java/org/springframework/cloud/task/batch/autoconfigure/RangeConverter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2020 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.cloud.task.batch.autoconfigure; 18 | 19 | import org.springframework.batch.item.file.transform.Range; 20 | import org.springframework.core.convert.converter.Converter; 21 | 22 | /** 23 | * Converter for taking properties of format {@code start-end} or {@code start} (where 24 | * start and end are both integers) and converting them into {@link Range} instances for 25 | * configuring a {@link org.springframework.batch.item.file.FlatFileItemReader}. 26 | * 27 | * @author Michael Minella 28 | * @since 2.3 29 | */ 30 | public class RangeConverter implements Converter { 31 | 32 | @Override 33 | public Range convert(String source) { 34 | if (source == null) { 35 | return null; 36 | } 37 | 38 | String[] columns = source.split("-"); 39 | 40 | if (columns.length == 1) { 41 | int start = Integer.parseInt(columns[0]); 42 | return new Range(start); 43 | } 44 | else if (columns.length == 2) { 45 | int start = Integer.parseInt(columns[0]); 46 | int end = Integer.parseInt(columns[1]); 47 | return new Range(start, end); 48 | } 49 | else { 50 | throw new IllegalArgumentException(String 51 | .format("%s is in an illegal format. Ranges must be specified as startIndex-endIndex", source)); 52 | } 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /spring-cloud-starter-single-step-batch-job/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports: -------------------------------------------------------------------------------- 1 | org.springframework.cloud.task.batch.autoconfigure.flatfile.FlatFileItemReaderAutoConfiguration 2 | org.springframework.cloud.task.batch.autoconfigure.RangeConverter 3 | org.springframework.cloud.task.batch.autoconfigure.SingleStepJobAutoConfiguration 4 | org.springframework.cloud.task.batch.autoconfigure.flatfile.FlatFileItemWriterAutoConfiguration 5 | org.springframework.cloud.task.batch.autoconfigure.jdbc.JdbcBatchItemWriterAutoConfiguration 6 | org.springframework.cloud.task.batch.autoconfigure.jdbc.JdbcCursorItemReaderAutoConfiguration 7 | org.springframework.cloud.task.batch.autoconfigure.rabbit.AmqpItemReaderAutoConfiguration 8 | org.springframework.cloud.task.batch.autoconfigure.rabbit.AmqpItemWriterAutoConfiguration 9 | org.springframework.cloud.task.batch.autoconfigure.kafka.KafkaItemReaderAutoConfiguration 10 | org.springframework.cloud.task.batch.autoconfigure.kafka.KafkaItemWriterAutoConfiguration 11 | 12 | -------------------------------------------------------------------------------- /spring-cloud-starter-single-step-batch-job/src/test/resources/logback-test.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /spring-cloud-starter-single-step-batch-job/src/test/resources/schema-h2.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE IF NOT EXISTS item 2 | ( 3 | item_name varchar(55) 4 | ); 5 | -------------------------------------------------------------------------------- /spring-cloud-starter-single-step-batch-job/src/test/resources/test.txt: -------------------------------------------------------------------------------- 1 | 1 2 3 4 5 six 2 | # This should be ignored 3 | 7 8 9 1011twelve 4 | $ So should this 5 | 1314151617eighteen 6 | 1920212223twenty four 7 | 1526272829thirty 8 | 3132333435thirty six 9 | -------------------------------------------------------------------------------- /spring-cloud-starter-single-step-batch-job/src/test/resources/testUTF16.csv: -------------------------------------------------------------------------------- 1 | 1@2@3@4@5@six 2 | # This should be ignored 3 | 7@8@9@10@11@twelve 4 | $ So should this 5 | 13@14@15@16@17@eighteen 6 | 19@20@21@22@23@%twenty four% 7 | 15@26@27@28@29@thirty 8 | 31@32@33@34@35@thirty six 9 | 37@38@39@40@41@forty two 10 | 43@44@45@46@47@forty eight 11 | 49@50@51@52@53@fifty four 12 | 55@56@57@58@59@sixty 13 | -------------------------------------------------------------------------------- /spring-cloud-starter-single-step-batch-job/src/test/resources/testUTF8.csv: -------------------------------------------------------------------------------- 1 | 1@2@3@4@5@six 2 | # This should be ignored 3 | 7@8@9@10@11@twelve 4 | $ So should this 5 | 13@14@15@16@17@eighteen 6 | 19@20@21@22@23@%twenty four% 7 | 15@26@27@28@29@thirty 8 | 31@32@33@34@35@thirty six 9 | 37@38@39@40@41@forty two 10 | 43@44@45@46@47@forty eight 11 | 49@50@51@52@53@fifty four 12 | 55@56@57@58@59@sixty 13 | -------------------------------------------------------------------------------- /spring-cloud-starter-single-step-batch-job/src/test/resources/writerTestUTF16.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spring-cloud/spring-cloud-task/b9dfa48bb3b4970f68008340a28d31dfb79b8ea5/spring-cloud-starter-single-step-batch-job/src/test/resources/writerTestUTF16.txt -------------------------------------------------------------------------------- /spring-cloud-starter-task/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 4.0.0 5 | 6 | 7 | org.springframework.cloud 8 | spring-cloud-task-parent 9 | 3.3.1-SNAPSHOT 10 | 11 | 12 | spring-cloud-starter-task 13 | jar 14 | Spring Cloud Task Starter 15 | Spring Boot starter for Spring Cloud Task 16 | 17 | 18 | 19 | org.springframework.boot 20 | spring-boot-starter 21 | 22 | 23 | org.springframework.cloud 24 | spring-cloud-task-core 25 | 26 | 27 | org.springframework.cloud 28 | spring-cloud-task-batch 29 | 30 | 31 | org.springframework.cloud 32 | spring-cloud-task-stream 33 | 34 | 35 | org.springframework.boot 36 | spring-boot-starter-jdbc 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /spring-cloud-task-batch/src/main/java/org/springframework/cloud/task/batch/configuration/JobLaunchCondition.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.cloud.task.batch.configuration; 18 | 19 | import org.springframework.boot.autoconfigure.condition.AllNestedConditions; 20 | import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; 21 | 22 | /** 23 | * Evaluates if the correct conditions have been met to create a TaskJobLauncher. 24 | * 25 | * @author Glenn Renfro 26 | * @since 2.2.0 27 | */ 28 | public class JobLaunchCondition extends AllNestedConditions { 29 | 30 | public JobLaunchCondition() { 31 | super(ConfigurationPhase.PARSE_CONFIGURATION); 32 | } 33 | 34 | @ConditionalOnProperty(name = "spring.cloud.task.batch.fail-on-job-failure", havingValue = "true") 35 | static class FailOnJobFailureCondition { 36 | 37 | } 38 | 39 | @ConditionalOnProperty(prefix = "spring.batch.job", name = "enabled", havingValue = "true", matchIfMissing = true) 40 | static class SpringBatchJobCondition { 41 | 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /spring-cloud-task-batch/src/main/java/org/springframework/cloud/task/batch/listener/TaskBatchDao.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.cloud.task.batch.listener; 18 | 19 | import org.springframework.batch.core.JobExecution; 20 | import org.springframework.cloud.task.repository.TaskExecution; 21 | 22 | /** 23 | * Maintains the association between a {@link TaskExecution} and a {@link JobExecution} 24 | * executed within it. 25 | * 26 | * @author Michael Minella 27 | */ 28 | public interface TaskBatchDao { 29 | 30 | /** 31 | * Saves the relationship between a task execution and a job execution. 32 | * @param taskExecution task execution 33 | * @param jobExecution job execution 34 | */ 35 | void saveRelationship(TaskExecution taskExecution, JobExecution jobExecution); 36 | 37 | } 38 | -------------------------------------------------------------------------------- /spring-cloud-task-batch/src/main/java/org/springframework/cloud/task/batch/partition/CommandLineArgsProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.cloud.task.batch.partition; 18 | 19 | import java.util.List; 20 | 21 | import org.springframework.batch.item.ExecutionContext; 22 | 23 | /** 24 | * Strategy to allow for the customization of command line arguments passed to each 25 | * partition's execution. 26 | * 27 | * @author Michael Minella 28 | * @since 1.1.0 29 | * @deprecated This feature is now end-of-life and will be removed in a future release. No 30 | * replacement is planned. Please migrate away from using this functionality. 31 | */ 32 | @Deprecated 33 | public interface CommandLineArgsProvider { 34 | 35 | /** 36 | * Returns a unique list of command line arguements to be passed to the partition's 37 | * worker for the specified {@link ExecutionContext}. 38 | * 39 | * Note: This method is called once per partition. 40 | * @param executionContext the unique state for the step to be executed. 41 | * @return a list of formatted command line arguments to be passed to the worker (the 42 | * list will be joined via spaces). 43 | */ 44 | List getCommandLineArgs(ExecutionContext executionContext); 45 | 46 | } 47 | -------------------------------------------------------------------------------- /spring-cloud-task-batch/src/main/java/org/springframework/cloud/task/batch/partition/EnvironmentVariablesProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.cloud.task.batch.partition; 18 | 19 | import java.util.Map; 20 | 21 | import org.springframework.batch.item.ExecutionContext; 22 | 23 | /** 24 | * Strategy interface to allow for advanced configuration of environment variables for 25 | * each worker in a partitioned job. 26 | * 27 | * @author Michael Minella 28 | * @since 1.0.2 29 | * @deprecated This feature is now end-of-life and will be removed in a future release. No 30 | * replacement is planned. Please migrate away from using this functionality. 31 | */ 32 | @Deprecated 33 | public interface EnvironmentVariablesProvider { 34 | 35 | /** 36 | * Provides a {@link Map} of Strings to be used as environment variables. This method 37 | * will be called for each worker step. For example, if there are 5 partitions, this 38 | * method will be called 5 times. 39 | * @param executionContext the {@link ExecutionContext} associated with the worker's 40 | * step 41 | * @return A {@link Map} of values to be used as environment variables 42 | */ 43 | Map getEnvironmentVariables(ExecutionContext executionContext); 44 | 45 | } 46 | -------------------------------------------------------------------------------- /spring-cloud-task-batch/src/main/java/org/springframework/cloud/task/batch/partition/NoOpEnvironmentVariablesProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.cloud.task.batch.partition; 18 | 19 | import java.util.Collections; 20 | import java.util.Map; 21 | 22 | import org.springframework.batch.item.ExecutionContext; 23 | 24 | /** 25 | * A simple no-op implementation of the {@link EnvironmentVariablesProvider}. It returns 26 | * an empty {@link Map}. 27 | * 28 | * @author Michael Minella 29 | * @since 1.0.2 30 | * @deprecated This feature is now end-of-life and will be removed in a future release. No 31 | * replacement is planned. Please migrate away from using this functionality. 32 | */ 33 | @Deprecated 34 | public class NoOpEnvironmentVariablesProvider implements EnvironmentVariablesProvider { 35 | 36 | /** 37 | * @param executionContext the {@link ExecutionContext} associated with the worker's 38 | * step 39 | * @return an empty {@link Map} 40 | */ 41 | @Override 42 | public Map getEnvironmentVariables(ExecutionContext executionContext) { 43 | return Collections.emptyMap(); 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /spring-cloud-task-batch/src/main/java/org/springframework/cloud/task/batch/partition/PassThroughCommandLineArgsProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.cloud.task.batch.partition; 18 | 19 | import java.util.List; 20 | 21 | import org.springframework.batch.item.ExecutionContext; 22 | import org.springframework.util.Assert; 23 | 24 | /** 25 | * Returns the {@code List} provided. 26 | * 27 | * @author Michael Minella 28 | * @since 1.1.0 29 | * @deprecated This feature is now end-of-life and will be removed in a future release. No 30 | * replacement is planned. Please migrate away from using this functionality. 31 | */ 32 | @Deprecated 33 | public class PassThroughCommandLineArgsProvider implements CommandLineArgsProvider { 34 | 35 | private final List commandLineArgs; 36 | 37 | public PassThroughCommandLineArgsProvider(List commandLineArgs) { 38 | Assert.notNull(commandLineArgs, "commandLineArgs is required"); 39 | 40 | this.commandLineArgs = commandLineArgs; 41 | } 42 | 43 | @Override 44 | public List getCommandLineArgs(ExecutionContext executionContext) { 45 | return this.commandLineArgs; 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /spring-cloud-task-batch/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports: -------------------------------------------------------------------------------- 1 | org.springframework.cloud.task.batch.configuration.TaskBatchAutoConfiguration 2 | org.springframework.cloud.task.batch.configuration.TaskJobLauncherAutoConfiguration 3 | -------------------------------------------------------------------------------- /spring-cloud-task-batch/src/test/java/org/springframework/cloud/task/batch/configuration/TaskBatchTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.cloud.task.batch.configuration; 18 | 19 | import java.lang.annotation.Documented; 20 | import java.lang.annotation.ElementType; 21 | import java.lang.annotation.Retention; 22 | import java.lang.annotation.RetentionPolicy; 23 | import java.lang.annotation.Target; 24 | 25 | import org.springframework.boot.autoconfigure.ImportAutoConfiguration; 26 | 27 | /** 28 | * Contains the common configurations to run a unit test for the task batch features of 29 | * SCT. 30 | * 31 | * @author Glenn Renfro 32 | */ 33 | @Target(ElementType.TYPE) 34 | @Retention(RetentionPolicy.RUNTIME) 35 | @Documented 36 | @ImportAutoConfiguration 37 | public @interface TaskBatchTest { 38 | 39 | } 40 | -------------------------------------------------------------------------------- /spring-cloud-task-batch/src/test/java/org/springframework/cloud/task/batch/partition/NoOpEnvironmentVariablesProviderTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.cloud.task.batch.partition; 18 | 19 | import java.util.Map; 20 | 21 | import org.junit.jupiter.api.BeforeEach; 22 | import org.junit.jupiter.api.Test; 23 | 24 | import static org.assertj.core.api.Assertions.assertThat; 25 | 26 | /** 27 | * @author Michael Minella 28 | */ 29 | public class NoOpEnvironmentVariablesProviderTests { 30 | 31 | private NoOpEnvironmentVariablesProvider provider; 32 | 33 | @BeforeEach 34 | public void setUp() { 35 | this.provider = new NoOpEnvironmentVariablesProvider(); 36 | } 37 | 38 | @Test 39 | public void test() { 40 | Map environmentVariables = this.provider.getEnvironmentVariables(null); 41 | assertThat(environmentVariables).isNotNull(); 42 | assertThat(environmentVariables.isEmpty()).isTrue(); 43 | 44 | Map environmentVariables2 = this.provider.getEnvironmentVariables(null); 45 | assertThat(environmentVariables == environmentVariables2).isTrue(); 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /spring-cloud-task-batch/src/test/java/org/springframework/cloud/task/batch/partition/PassThroughCommandLineArgsProviderTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.cloud.task.batch.partition; 18 | 19 | import java.util.Arrays; 20 | import java.util.List; 21 | 22 | import org.junit.jupiter.api.Test; 23 | 24 | import static org.assertj.core.api.Assertions.assertThat; 25 | import static org.assertj.core.api.Assertions.assertThatExceptionOfType; 26 | 27 | /** 28 | * @author Michael Minella 29 | */ 30 | public class PassThroughCommandLineArgsProviderTests { 31 | 32 | @Test 33 | public void testNull() { 34 | assertThatExceptionOfType(IllegalArgumentException.class).isThrownBy(() -> { 35 | new PassThroughCommandLineArgsProvider(null); 36 | }); 37 | } 38 | 39 | @Test 40 | public void test() { 41 | List args = Arrays.asList("foo", "bar", "baz"); 42 | 43 | CommandLineArgsProvider provider = new PassThroughCommandLineArgsProvider(args); 44 | 45 | List commandLineArgs = provider.getCommandLineArgs(null); 46 | 47 | assertThat(commandLineArgs.get(0)).isEqualTo("foo"); 48 | assertThat(commandLineArgs.get(1)).isEqualTo("bar"); 49 | assertThat(commandLineArgs.get(2)).isEqualTo("baz"); 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /spring-cloud-task-batch/src/test/resources/META-INF/spring/org.springframework.cloud.task.batch.configuration.TaskBatchTest.imports: -------------------------------------------------------------------------------- 1 | org.springframework.cloud.task.batch.configuration.TaskBatchAutoConfiguration 2 | org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration 3 | org.springframework.boot.autoconfigure.batch.BatchAutoConfiguration 4 | org.springframework.cloud.task.configuration.SimpleTaskAutoConfiguration 5 | org.springframework.cloud.task.configuration.SingleTaskConfiguration 6 | -------------------------------------------------------------------------------- /spring-cloud-task-batch/src/test/resources/schema-h2.sql: -------------------------------------------------------------------------------- 1 | 2 | CREATE TABLE FOO_EXECUTION ( 3 | TASK_EXECUTION_ID BIGINT NOT NULL PRIMARY KEY , 4 | START_TIME TIMESTAMP DEFAULT NULL , 5 | END_TIME TIMESTAMP DEFAULT NULL , 6 | TASK_NAME VARCHAR(100) , 7 | EXIT_CODE INTEGER , 8 | EXIT_MESSAGE VARCHAR(2500) , 9 | ERROR_MESSAGE VARCHAR(2500) , 10 | LAST_UPDATED TIMESTAMP, 11 | EXTERNAL_EXECUTION_ID VARCHAR(255), 12 | PARENT_EXECUTION_ID BIGINT 13 | ); 14 | 15 | CREATE TABLE FOO_EXECUTION_PARAMS ( 16 | TASK_EXECUTION_ID BIGINT NOT NULL , 17 | TASK_PARAM VARCHAR(2500) , 18 | constraint TASK_EXEC_PARAMS_FK foreign key (TASK_EXECUTION_ID) 19 | references FOO_EXECUTION(TASK_EXECUTION_ID) 20 | ) ; 21 | 22 | CREATE TABLE FOO_TASK_BATCH ( 23 | TASK_EXECUTION_ID BIGINT NOT NULL , 24 | JOB_EXECUTION_ID BIGINT NOT NULL , 25 | constraint TASK_EXEC_BATCH_FK foreign key (TASK_EXECUTION_ID) 26 | references FOO_EXECUTION(TASK_EXECUTION_ID) 27 | ) ; 28 | 29 | CREATE SEQUENCE FOO_SEQ ; 30 | 31 | CREATE TABLE FOO_LOCK ( 32 | LOCK_KEY CHAR(36) NOT NULL, 33 | REGION VARCHAR(100) NOT NULL, 34 | CLIENT_ID CHAR(36), 35 | CREATED_DATE TIMESTAMP NOT NULL, 36 | constraint LOCK_PK primary key (LOCK_KEY, REGION) 37 | ); 38 | -------------------------------------------------------------------------------- /spring-cloud-task-batch/src/test/resources/schema-with-primary-keys-h2.sql: -------------------------------------------------------------------------------- 1 | 2 | CREATE TABLE TASK_EXECUTION ( 3 | TASK_EXECUTION_ID BIGINT NOT NULL PRIMARY KEY , 4 | START_TIME TIMESTAMP DEFAULT NULL , 5 | END_TIME TIMESTAMP DEFAULT NULL , 6 | TASK_NAME VARCHAR(100) , 7 | EXIT_CODE INTEGER , 8 | EXIT_MESSAGE VARCHAR(2500) , 9 | ERROR_MESSAGE VARCHAR(2500) , 10 | LAST_UPDATED TIMESTAMP, 11 | EXTERNAL_EXECUTION_ID VARCHAR(255), 12 | PARENT_EXECUTION_ID BIGINT 13 | ); 14 | 15 | CREATE TABLE TASK_EXECUTION_PARAMS ( 16 | ID BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY, 17 | TASK_EXECUTION_ID BIGINT NOT NULL , 18 | TASK_PARAM VARCHAR(2500) , 19 | constraint TASK_EXEC_PARAMS_FK foreign key (TASK_EXECUTION_ID) 20 | references TASK_EXECUTION(TASK_EXECUTION_ID) 21 | ) ; 22 | 23 | CREATE TABLE TASK_TASK_BATCH ( 24 | ID BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY, 25 | TASK_EXECUTION_ID BIGINT NOT NULL , 26 | JOB_EXECUTION_ID BIGINT NOT NULL , 27 | constraint TASK_EXEC_BATCH_FK foreign key (TASK_EXECUTION_ID) 28 | references TASK_EXECUTION(TASK_EXECUTION_ID) 29 | ) ; 30 | 31 | CREATE SEQUENCE TASK_SEQ ; 32 | 33 | CREATE TABLE TASK_LOCK ( 34 | LOCK_KEY CHAR(36) NOT NULL, 35 | REGION VARCHAR(100) NOT NULL, 36 | CLIENT_ID CHAR(36), 37 | CREATED_DATE TIMESTAMP NOT NULL, 38 | constraint LOCK_PK primary key (LOCK_KEY, REGION) 39 | ); 40 | -------------------------------------------------------------------------------- /spring-cloud-task-core/src/main/java/org/springframework/cloud/task/configuration/EnableTask.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.cloud.task.configuration; 18 | 19 | import java.lang.annotation.Documented; 20 | import java.lang.annotation.ElementType; 21 | import java.lang.annotation.Inherited; 22 | import java.lang.annotation.Retention; 23 | import java.lang.annotation.RetentionPolicy; 24 | import java.lang.annotation.Target; 25 | 26 | import org.springframework.context.annotation.Import; 27 | 28 | /** 29 | *

30 | * Enables the {@link org.springframework.cloud.task.listener.TaskLifecycleListener} so 31 | * that the features of Spring Cloud Task will be applied. 32 | * 33 | *

34 |  * @Configuration
35 |  * @EnableTask
36 |  * public class AppConfig {
37 |  *
38 |  * 	@Bean
39 |  * 	public MyCommandLineRunner myCommandLineRunner() {
40 |  * 		return new MyCommandLineRunner()
41 |  *    }
42 |  * }
43 |  * 
44 | * 45 | * Note that only one of your configuration classes needs to have the 46 | * @EnableTask annotation. Once you have an 47 | * @EnableTask class in your configuration the task will have the Spring 48 | * Cloud Task features available. 49 | * 50 | * @author Glenn Renfro 51 | * 52 | */ 53 | @Target(ElementType.TYPE) 54 | @Retention(RetentionPolicy.RUNTIME) 55 | @Documented 56 | @Inherited 57 | @Import(TaskLifecycleConfiguration.class) 58 | public @interface EnableTask { 59 | 60 | } 61 | -------------------------------------------------------------------------------- /spring-cloud-task-core/src/main/java/org/springframework/cloud/task/configuration/NoTransactionManagerProperty.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022-2022 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.cloud.task.configuration; 18 | 19 | import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; 20 | import org.springframework.boot.autoconfigure.condition.NoneNestedConditions; 21 | 22 | /** 23 | * A condition that verifies that the spring.cloud.task.transaction-manager property is 24 | * not being used. 25 | * 26 | * @author Glenn Renfro 27 | * @since 3.0 28 | */ 29 | class NoTransactionManagerProperty extends NoneNestedConditions { 30 | 31 | NoTransactionManagerProperty() { 32 | super(ConfigurationPhase.REGISTER_BEAN); 33 | } 34 | 35 | @ConditionalOnProperty(prefix = "spring.cloud.task", name = "transaction-manager") 36 | static class OnProperty { 37 | 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /spring-cloud-task-core/src/main/java/org/springframework/cloud/task/configuration/TaskRepositoryDatabaseInitializerDetector.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022-2022 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.cloud.task.configuration; 18 | 19 | import java.util.Set; 20 | 21 | import org.springframework.boot.sql.init.dependency.AbstractBeansOfTypeDatabaseInitializerDetector; 22 | import org.springframework.boot.sql.init.dependency.DatabaseInitializerDetector; 23 | import org.springframework.cloud.task.repository.support.TaskRepositoryInitializer; 24 | import org.springframework.core.Ordered; 25 | 26 | /** 27 | * {@link DatabaseInitializerDetector} for {@link TaskRepositoryInitializer}. 28 | * 29 | * @author Henning Pöttker 30 | */ 31 | class TaskRepositoryDatabaseInitializerDetector extends AbstractBeansOfTypeDatabaseInitializerDetector { 32 | 33 | private static final int PRECEDENCE = Ordered.LOWEST_PRECEDENCE - 99; 34 | 35 | @Override 36 | protected Set> getDatabaseInitializerBeanTypes() { 37 | return Set.of(TaskRepositoryInitializer.class); 38 | } 39 | 40 | @Override 41 | public int getOrder() { 42 | return PRECEDENCE; 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /spring-cloud-task-core/src/main/java/org/springframework/cloud/task/configuration/TaskRepositoryDependsOnDatabaseInitializationDetector.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022-2022 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.cloud.task.configuration; 18 | 19 | import java.util.Set; 20 | 21 | import org.springframework.boot.sql.init.dependency.AbstractBeansOfTypeDependsOnDatabaseInitializationDetector; 22 | import org.springframework.boot.sql.init.dependency.DependsOnDatabaseInitializationDetector; 23 | import org.springframework.cloud.task.repository.TaskRepository; 24 | 25 | /** 26 | * {@link DependsOnDatabaseInitializationDetector} for {@link TaskRepository}. 27 | * 28 | * @author Henning Pöttker 29 | */ 30 | class TaskRepositoryDependsOnDatabaseInitializationDetector 31 | extends AbstractBeansOfTypeDependsOnDatabaseInitializationDetector { 32 | 33 | @Override 34 | protected Set> getDependsOnDatabaseInitializationBeanTypes() { 35 | return Set.of(TaskRepository.class); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /spring-cloud-task-core/src/main/java/org/springframework/cloud/task/configuration/observation/DefaultTaskObservationConvention.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013-2022 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.cloud.task.configuration.observation; 18 | 19 | import io.micrometer.common.KeyValues; 20 | import io.micrometer.observation.ObservationConvention; 21 | 22 | /** 23 | * {@link ObservationConvention} for Spring Cloud Task. 24 | * 25 | * @author Marcin Grzejszczak 26 | * @since 3.0.0 27 | */ 28 | public class DefaultTaskObservationConvention implements TaskObservationConvention { 29 | 30 | @Override 31 | public KeyValues getLowCardinalityKeyValues(TaskObservationContext context) { 32 | return KeyValues.of(TaskDocumentedObservation.TaskRunnerTags.BEAN_NAME.withValue(context.getBeanName())); 33 | } 34 | 35 | @Override 36 | public String getName() { 37 | return "spring.cloud.task.runner"; 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /spring-cloud-task-core/src/main/java/org/springframework/cloud/task/configuration/observation/ObservationApplicationRunnerBeanPostProcessor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013-2022 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.cloud.task.configuration.observation; 18 | 19 | import org.springframework.beans.BeansException; 20 | import org.springframework.beans.factory.BeanFactory; 21 | import org.springframework.beans.factory.config.BeanPostProcessor; 22 | import org.springframework.boot.ApplicationRunner; 23 | 24 | /** 25 | * Registers beans related to task scheduling. 26 | * 27 | * @author Marcin Grzejszczak 28 | */ 29 | class ObservationApplicationRunnerBeanPostProcessor implements BeanPostProcessor { 30 | 31 | private final BeanFactory beanFactory; 32 | 33 | ObservationApplicationRunnerBeanPostProcessor(BeanFactory beanFactory) { 34 | this.beanFactory = beanFactory; 35 | } 36 | 37 | @Override 38 | public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException { 39 | if (bean instanceof ApplicationRunner applicationRunner && !(bean instanceof ObservationApplicationRunner)) { 40 | return new ObservationApplicationRunner(this.beanFactory, applicationRunner, beanName); 41 | } 42 | return bean; 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /spring-cloud-task-core/src/main/java/org/springframework/cloud/task/configuration/observation/ObservationCommandLineRunnerBeanPostProcessor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013-2022 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.cloud.task.configuration.observation; 18 | 19 | import org.springframework.beans.BeansException; 20 | import org.springframework.beans.factory.BeanFactory; 21 | import org.springframework.beans.factory.config.BeanPostProcessor; 22 | import org.springframework.boot.CommandLineRunner; 23 | 24 | /** 25 | * Registers beans related to task scheduling. 26 | * 27 | * @author Marcin Grzejszczak 28 | */ 29 | class ObservationCommandLineRunnerBeanPostProcessor implements BeanPostProcessor { 30 | 31 | private final BeanFactory beanFactory; 32 | 33 | ObservationCommandLineRunnerBeanPostProcessor(BeanFactory beanFactory) { 34 | this.beanFactory = beanFactory; 35 | } 36 | 37 | @Override 38 | public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException { 39 | if (bean instanceof CommandLineRunner commandLineRunner && !(bean instanceof ObservationCommandLineRunner)) { 40 | return new ObservationCommandLineRunner(this.beanFactory, commandLineRunner, beanName); 41 | } 42 | return bean; 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /spring-cloud-task-core/src/main/java/org/springframework/cloud/task/configuration/observation/TaskDocumentedObservation.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013-2022 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.cloud.task.configuration.observation; 18 | 19 | import io.micrometer.common.docs.KeyName; 20 | import io.micrometer.observation.Observation; 21 | import io.micrometer.observation.ObservationConvention; 22 | import io.micrometer.observation.docs.ObservationDocumentation; 23 | 24 | enum TaskDocumentedObservation implements ObservationDocumentation { 25 | 26 | /** 27 | * Observation created when a task runner is executed. 28 | */ 29 | TASK_RUNNER_OBSERVATION { 30 | 31 | @Override 32 | public Class> getDefaultConvention() { 33 | return DefaultTaskObservationConvention.class; 34 | } 35 | 36 | @Override 37 | public KeyName[] getLowCardinalityKeyNames() { 38 | return TaskRunnerTags.values(); 39 | } 40 | 41 | @Override 42 | public String getPrefix() { 43 | return "spring.cloud.task"; 44 | } 45 | }; 46 | 47 | /** 48 | * Key names for Spring Cloud Task Command / Application runners. 49 | */ 50 | enum TaskRunnerTags implements KeyName { 51 | 52 | /** 53 | * Name of the bean that was executed by Spring Cloud Task. 54 | */ 55 | BEAN_NAME { 56 | @Override 57 | public String asString() { 58 | return "spring.cloud.task.runner.bean-name"; 59 | } 60 | } 61 | 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /spring-cloud-task-core/src/main/java/org/springframework/cloud/task/configuration/observation/TaskObservationContext.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013-2022 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.cloud.task.configuration.observation; 18 | 19 | import java.util.function.Supplier; 20 | 21 | import io.micrometer.observation.Observation; 22 | 23 | /** 24 | * {@link Observation.Context} for Spring Cloud Task. 25 | * 26 | * @author Marcin Grzejszczak 27 | * @since 3.0.0 28 | */ 29 | public class TaskObservationContext extends Observation.Context implements Supplier { 30 | 31 | private final String beanName; 32 | 33 | public TaskObservationContext(String beanName) { 34 | this.beanName = beanName; 35 | } 36 | 37 | public String getBeanName() { 38 | return beanName; 39 | } 40 | 41 | @Override 42 | public TaskObservationContext get() { 43 | return this; 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /spring-cloud-task-core/src/main/java/org/springframework/cloud/task/configuration/observation/TaskObservationConvention.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013-2022 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.cloud.task.configuration.observation; 18 | 19 | import io.micrometer.observation.Observation; 20 | import io.micrometer.observation.ObservationConvention; 21 | 22 | /** 23 | * {@link ObservationConvention} for Spring Cloud Task. 24 | * 25 | * @author Marcin Grzejszczak 26 | * @since 3.0.0 27 | */ 28 | public interface TaskObservationConvention extends ObservationConvention { 29 | 30 | @Override 31 | default boolean supportsContext(Observation.Context context) { 32 | return context instanceof TaskObservationContext; 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /spring-cloud-task-core/src/main/java/org/springframework/cloud/task/configuration/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * Interfaces for configuring Spring Cloud Task and a default implementations. 19 | */ 20 | package org.springframework.cloud.task.configuration; 21 | -------------------------------------------------------------------------------- /spring-cloud-task-core/src/main/java/org/springframework/cloud/task/listener/DefaultTaskExecutionObservationConvention.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022-2022 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.cloud.task.listener; 18 | 19 | import io.micrometer.common.KeyValues; 20 | 21 | import org.springframework.cloud.task.repository.TaskExecution; 22 | 23 | /** 24 | * /** Default {@link TaskExecutionObservationConvention} implementation. 25 | * 26 | * @author Glenn Renfro 27 | * @since 3.0.0 28 | */ 29 | public class DefaultTaskExecutionObservationConvention implements TaskExecutionObservationConvention { 30 | 31 | @Override 32 | public KeyValues getLowCardinalityKeyValues(TaskExecutionObservationContext context) { 33 | return getKeyValuesForTaskExecution(context); 34 | } 35 | 36 | @Override 37 | public KeyValues getHighCardinalityKeyValues(TaskExecutionObservationContext context) { 38 | return KeyValues.empty(); 39 | } 40 | 41 | private KeyValues getKeyValuesForTaskExecution(TaskExecutionObservationContext context) { 42 | TaskExecution execution = context.getTaskExecution(); 43 | return KeyValues.of(TaskExecutionObservation.TaskKeyValues.TASK_STATUS.asString(), context.getStatus(), 44 | TaskExecutionObservation.TaskKeyValues.TASK_EXIT_CODE.asString(), 45 | String.valueOf(execution.getExitCode()), 46 | TaskExecutionObservation.TaskKeyValues.TASK_EXECUTION_ID.asString(), 47 | String.valueOf(execution.getExecutionId())); 48 | } 49 | 50 | @Override 51 | public String getName() { 52 | return "spring.cloud.task"; 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /spring-cloud-task-core/src/main/java/org/springframework/cloud/task/listener/TaskException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.cloud.task.listener; 18 | 19 | /** 20 | * Base Exception for any Task issues. 21 | * 22 | * @author Glenn Renfro 23 | */ 24 | public class TaskException extends RuntimeException { 25 | 26 | public TaskException(String message, Throwable e) { 27 | super(message, e); 28 | } 29 | 30 | public TaskException(String message) { 31 | super(message); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /spring-cloud-task-core/src/main/java/org/springframework/cloud/task/listener/TaskExecutionException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.cloud.task.listener; 18 | 19 | /** 20 | * Is thrown when executing a task. 21 | * 22 | * @author Glenn Renfro. 23 | */ 24 | public class TaskExecutionException extends TaskException { 25 | 26 | public TaskExecutionException(String message) { 27 | super(message); 28 | } 29 | 30 | public TaskExecutionException(String message, Throwable throwable) { 31 | super(message, throwable); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /spring-cloud-task-core/src/main/java/org/springframework/cloud/task/listener/TaskExecutionListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2022 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.cloud.task.listener; 18 | 19 | import org.springframework.cloud.task.repository.TaskExecution; 20 | import org.springframework.cloud.task.repository.TaskRepository; 21 | 22 | /** 23 | * The listener interface for receiving task execution events. 24 | * 25 | * @author Glenn Renfro 26 | */ 27 | public interface TaskExecutionListener { 28 | 29 | /** 30 | * Invoked after the {@link TaskExecution} has been stored in the 31 | * {@link TaskRepository}. 32 | * @param taskExecution instance containing the information about the current task. 33 | */ 34 | default void onTaskStartup(TaskExecution taskExecution) { 35 | } 36 | 37 | /** 38 | * Invoked before the {@link TaskExecution} has been updated in the 39 | * {@link TaskRepository} upon task end. 40 | * @param taskExecution instance containing the information about the current task. 41 | */ 42 | default void onTaskEnd(TaskExecution taskExecution) { 43 | } 44 | 45 | /** 46 | * Invoked if an uncaught exception occurs during a task execution. This invocation 47 | * will occur before the {@link TaskExecution} has been updated in the 48 | * {@link TaskRepository} and before the onTaskEnd is called. 49 | * @param taskExecution instance containing the information about the current task. 50 | * @param throwable the uncaught exception that was thrown during task execution. 51 | */ 52 | default void onTaskFailed(TaskExecution taskExecution, Throwable throwable) { 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /spring-cloud-task-core/src/main/java/org/springframework/cloud/task/listener/TaskExecutionListenerSupport.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017-2022 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.cloud.task.listener; 18 | 19 | /** 20 | * A no-op implementation of the {@link TaskExecutionListener} to allow for overriding 21 | * only the methods of interest. 22 | * 23 | * @author Michael Minella 24 | * @since 1.2 25 | * 26 | * {@link TaskExecutionListener} 27 | * @deprecated since 3.0 in favor of the default implementations of 28 | */ 29 | @Deprecated 30 | public class TaskExecutionListenerSupport implements TaskExecutionListener { 31 | 32 | } 33 | -------------------------------------------------------------------------------- /spring-cloud-task-core/src/main/java/org/springframework/cloud/task/listener/TaskExecutionObservationContext.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022-2022 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.cloud.task.listener; 18 | 19 | import java.util.function.Supplier; 20 | 21 | import io.micrometer.observation.Observation; 22 | import io.micrometer.observation.ObservationHandler; 23 | 24 | import org.springframework.cloud.task.repository.TaskExecution; 25 | 26 | /** 27 | * A mutable holder of the {@link TaskExecution} required by a {@link ObservationHandler}. 28 | * 29 | * @author Glenn Renfro 30 | * @since 3.0.0 31 | */ 32 | public class TaskExecutionObservationContext extends Observation.Context 33 | implements Supplier { 34 | 35 | private final TaskExecution taskExecution; 36 | 37 | private String exceptionMessage = "none"; 38 | 39 | private String status = "success"; 40 | 41 | public TaskExecutionObservationContext(TaskExecution taskExecution) { 42 | this.taskExecution = taskExecution; 43 | } 44 | 45 | public TaskExecution getTaskExecution() { 46 | return taskExecution; 47 | } 48 | 49 | public String getExceptionMessage() { 50 | return exceptionMessage; 51 | } 52 | 53 | public void setExceptionMessage(String exceptionMessage) { 54 | this.exceptionMessage = exceptionMessage; 55 | } 56 | 57 | public String getStatus() { 58 | return status; 59 | } 60 | 61 | public void setStatus(String status) { 62 | this.status = status; 63 | } 64 | 65 | @Override 66 | public TaskExecutionObservationContext get() { 67 | return this; 68 | } 69 | 70 | } 71 | -------------------------------------------------------------------------------- /spring-cloud-task-core/src/main/java/org/springframework/cloud/task/listener/TaskExecutionObservationConvention.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022-2022 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.cloud.task.listener; 18 | 19 | import io.micrometer.observation.Observation; 20 | import io.micrometer.observation.ObservationConvention; 21 | 22 | /** 23 | * {@link ObservationConvention} for {@link TaskExecutionObservationContext}. 24 | * 25 | * @author Glenn Renfro 26 | * @since 3.0.0 27 | */ 28 | public interface TaskExecutionObservationConvention extends ObservationConvention { 29 | 30 | @Override 31 | default boolean supportsContext(Observation.Context context) { 32 | return context instanceof TaskExecutionObservationContext; 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /spring-cloud-task-core/src/main/java/org/springframework/cloud/task/listener/annotation/AfterTask.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2022 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.cloud.task.listener.annotation; 18 | 19 | import java.lang.annotation.Documented; 20 | import java.lang.annotation.ElementType; 21 | import java.lang.annotation.Retention; 22 | import java.lang.annotation.RetentionPolicy; 23 | import java.lang.annotation.Target; 24 | 25 | import org.springframework.aot.hint.annotation.Reflective; 26 | import org.springframework.cloud.task.listener.TaskExecutionListener; 27 | import org.springframework.cloud.task.repository.TaskExecution; 28 | 29 | /** 30 | *

31 | * {@link TaskExecutionListener#onTaskEnd(TaskExecution)}. 32 | *

33 | * 34 | *
35 |  * public class MyListener {
36 |  * 	@AfterTask
37 |  * 	public void  doSomething(TaskExecution taskExecution) {
38 |  *    }
39 |  * }
40 |  * 
41 | * 42 | * @author Glenn Renfro 43 | */ 44 | @Target({ ElementType.METHOD, ElementType.ANNOTATION_TYPE }) 45 | @Retention(RetentionPolicy.RUNTIME) 46 | @Documented 47 | @Reflective 48 | public @interface AfterTask { 49 | 50 | } 51 | -------------------------------------------------------------------------------- /spring-cloud-task-core/src/main/java/org/springframework/cloud/task/listener/annotation/BeforeTask.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2022 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.cloud.task.listener.annotation; 18 | 19 | import java.lang.annotation.Documented; 20 | import java.lang.annotation.ElementType; 21 | import java.lang.annotation.Retention; 22 | import java.lang.annotation.RetentionPolicy; 23 | import java.lang.annotation.Target; 24 | 25 | import org.springframework.aot.hint.annotation.Reflective; 26 | import org.springframework.cloud.task.listener.TaskExecutionListener; 27 | import org.springframework.cloud.task.repository.TaskExecution; 28 | 29 | /** 30 | *

31 | * {@link TaskExecutionListener#onTaskStartup(TaskExecution)}. 32 | *

33 | * 34 | *
35 |  * public class MyListener {
36 |  * 	@BeforeTask
37 |  * 	public void  doSomething(TaskExecution taskExecution) {
38 |  *    }
39 |  * }
40 |  * 
41 | * 42 | * @author Glenn Renfro 43 | */ 44 | @Target({ ElementType.METHOD, ElementType.ANNOTATION_TYPE }) 45 | @Retention(RetentionPolicy.RUNTIME) 46 | @Documented 47 | @Reflective 48 | public @interface BeforeTask { 49 | 50 | } 51 | -------------------------------------------------------------------------------- /spring-cloud-task-core/src/main/java/org/springframework/cloud/task/listener/annotation/FailedTask.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2022 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.cloud.task.listener.annotation; 18 | 19 | import java.lang.annotation.Documented; 20 | import java.lang.annotation.ElementType; 21 | import java.lang.annotation.Retention; 22 | import java.lang.annotation.RetentionPolicy; 23 | import java.lang.annotation.Target; 24 | 25 | import org.springframework.aot.hint.annotation.Reflective; 26 | import org.springframework.cloud.task.listener.TaskExecutionListener; 27 | import org.springframework.cloud.task.repository.TaskExecution; 28 | 29 | /** 30 | *

31 | * {@link TaskExecutionListener#onTaskFailed(TaskExecution, Throwable)}. 32 | *

33 | * 34 | *
35 |  * public class MyListener {
36 |  * 	@FailedTask
37 |  * 	public void  doSomething(TaskExecution taskExecution, Throwable throwable) {
38 |  *    }
39 |  * }
40 |  * 
41 | * 42 | * @author Glenn Renfro 43 | */ 44 | @Target({ ElementType.METHOD, ElementType.ANNOTATION_TYPE }) 45 | @Retention(RetentionPolicy.RUNTIME) 46 | @Documented 47 | @Reflective 48 | public @interface FailedTask { 49 | 50 | } 51 | -------------------------------------------------------------------------------- /spring-cloud-task-core/src/main/java/org/springframework/cloud/task/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * Base package for spring cloud task. 19 | */ 20 | package org.springframework.cloud.task; 21 | -------------------------------------------------------------------------------- /spring-cloud-task-core/src/main/java/org/springframework/cloud/task/repository/TaskNameResolver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.cloud.task.repository; 18 | 19 | /** 20 | * Strategy interface for customizing how the name of a task is determined. 21 | * 22 | * @author Michael Minella 23 | */ 24 | public interface TaskNameResolver { 25 | 26 | /** 27 | * @return the name of the task being executed within this context. 28 | */ 29 | String getTaskName(); 30 | 31 | } 32 | -------------------------------------------------------------------------------- /spring-cloud-task-core/src/main/java/org/springframework/cloud/task/repository/dao/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * Interface DAO and default implementations for storing and retrieving data for tasks 19 | * from a repository. 20 | */ 21 | package org.springframework.cloud.task.repository.dao; 22 | -------------------------------------------------------------------------------- /spring-cloud-task-core/src/main/java/org/springframework/cloud/task/repository/database/support/H2PagingQueryProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2022 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.cloud.task.repository.database.support; 18 | 19 | import org.springframework.cloud.task.repository.database.PagingQueryProvider; 20 | import org.springframework.data.domain.Pageable; 21 | 22 | /** 23 | * H2 implementation of a {@link PagingQueryProvider} using database specific features. 24 | * 25 | * @author Glenn Renfro 26 | * @author Henning Pöttker 27 | */ 28 | public class H2PagingQueryProvider extends AbstractSqlPagingQueryProvider { 29 | 30 | @Override 31 | public String getPageQuery(Pageable pageable) { 32 | String limitClause = new StringBuilder().append("OFFSET ") 33 | .append(pageable.getOffset()) 34 | .append(" ROWS FETCH NEXT ") 35 | .append(pageable.getPageSize()) 36 | .append(" ROWS ONLY") 37 | .toString(); 38 | return SqlPagingQueryUtils.generateLimitJumpToQuery(this, limitClause); 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /spring-cloud-task-core/src/main/java/org/springframework/cloud/task/repository/database/support/HsqlPagingQueryProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.cloud.task.repository.database.support; 18 | 19 | import org.springframework.cloud.task.repository.database.PagingQueryProvider; 20 | import org.springframework.data.domain.Pageable; 21 | 22 | /** 23 | * HSQLDB implementation of a {@link PagingQueryProvider} using database specific 24 | * features. 25 | * 26 | * @author Glenn Renfro 27 | */ 28 | public class HsqlPagingQueryProvider extends AbstractSqlPagingQueryProvider { 29 | 30 | @Override 31 | public String getPageQuery(Pageable pageable) { 32 | String topClause = new StringBuilder().append("LIMIT ") 33 | .append(pageable.getOffset()) 34 | .append(" ") 35 | .append(pageable.getPageSize()) 36 | .toString(); 37 | return SqlPagingQueryUtils.generateTopJumpToQuery(this, topClause); 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /spring-cloud-task-core/src/main/java/org/springframework/cloud/task/repository/database/support/MariaDbPagingQueryProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022-2022 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.cloud.task.repository.database.support; 18 | 19 | import org.springframework.cloud.task.repository.database.PagingQueryProvider; 20 | import org.springframework.data.domain.Pageable; 21 | 22 | /** 23 | * MariaDB implementation of a {@link PagingQueryProvider} using database specific 24 | * features. 25 | * 26 | * @author Glenn Renfro 27 | */ 28 | public class MariaDbPagingQueryProvider extends AbstractSqlPagingQueryProvider { 29 | 30 | @Override 31 | public String getPageQuery(Pageable pageable) { 32 | String topClause = new StringBuilder().append("LIMIT ") 33 | .append(pageable.getOffset()) 34 | .append(", ") 35 | .append(pageable.getPageSize()) 36 | .toString(); 37 | return SqlPagingQueryUtils.generateLimitJumpToQuery(this, topClause); 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /spring-cloud-task-core/src/main/java/org/springframework/cloud/task/repository/database/support/MySqlPagingQueryProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.cloud.task.repository.database.support; 18 | 19 | import org.springframework.cloud.task.repository.database.PagingQueryProvider; 20 | import org.springframework.data.domain.Pageable; 21 | 22 | /** 23 | * MySQL implementation of a {@link PagingQueryProvider} using database specific features. 24 | * 25 | * @author Glenn Renfro 26 | */ 27 | public class MySqlPagingQueryProvider extends AbstractSqlPagingQueryProvider { 28 | 29 | @Override 30 | public String getPageQuery(Pageable pageable) { 31 | String topClause = new StringBuilder().append("LIMIT ") 32 | .append(pageable.getOffset()) 33 | .append(", ") 34 | .append(pageable.getPageSize()) 35 | .toString(); 36 | return SqlPagingQueryUtils.generateLimitJumpToQuery(this, topClause); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /spring-cloud-task-core/src/main/java/org/springframework/cloud/task/repository/database/support/PostgresPagingQueryProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.cloud.task.repository.database.support; 18 | 19 | import org.springframework.cloud.task.repository.database.PagingQueryProvider; 20 | import org.springframework.data.domain.Pageable; 21 | 22 | /** 23 | * Postgres implementation of a {@link PagingQueryProvider} using database specific 24 | * features. 25 | * 26 | * @author Glenn Renfro 27 | */ 28 | public class PostgresPagingQueryProvider extends AbstractSqlPagingQueryProvider { 29 | 30 | @Override 31 | public String getPageQuery(Pageable pageable) { 32 | String limitClause = new StringBuilder().append("LIMIT ") 33 | .append(pageable.getPageSize()) 34 | .append(" OFFSET ") 35 | .append(pageable.getOffset()) 36 | .toString(); 37 | return SqlPagingQueryUtils.generateLimitJumpToQuery(this, limitClause); 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /spring-cloud-task-core/src/main/java/org/springframework/cloud/task/repository/support/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * Classes used for setting up and supporting a task repositories. 19 | */ 20 | package org.springframework.cloud.task.repository.support; 21 | -------------------------------------------------------------------------------- /spring-cloud-task-core/src/main/resources/META-INF/additional-spring-configuration-metadata.json: -------------------------------------------------------------------------------- 1 | { 2 | "properties": [ 3 | { 4 | "defaultValue": false, 5 | "name": "spring.cloud.task.single-instance-enabled", 6 | "description": "This property is used to determine if a task will execute if another task with the same app name is running.", 7 | "type": "java.lang.Boolean" 8 | },{ 9 | "defaultValue": "springCloudTaskTransactionManager", 10 | "name": "spring.cloud.task.transaction-manager", 11 | "description": "This property is used to specify the transaction manager for TaskRepository. By default, a dedicated transaction manager is created by spring.", 12 | "type": "java.lang.String" 13 | } 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /spring-cloud-task-core/src/main/resources/META-INF/spring.factories: -------------------------------------------------------------------------------- 1 | org.springframework.boot.sql.init.dependency.DatabaseInitializerDetector=\ 2 | org.springframework.cloud.task.configuration.TaskRepositoryDatabaseInitializerDetector 3 | 4 | org.springframework.boot.sql.init.dependency.DependsOnDatabaseInitializationDetector=\ 5 | org.springframework.cloud.task.configuration.TaskRepositoryDependsOnDatabaseInitializationDetector 6 | -------------------------------------------------------------------------------- /spring-cloud-task-core/src/main/resources/META-INF/spring/aot.factories: -------------------------------------------------------------------------------- 1 | org.springframework.aot.hint.RuntimeHintsRegistrar=\ 2 | org.springframework.cloud.task.configuration.TaskRuntimeHints 3 | -------------------------------------------------------------------------------- /spring-cloud-task-core/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports: -------------------------------------------------------------------------------- 1 | org.springframework.cloud.task.configuration.SingleTaskConfiguration 2 | org.springframework.cloud.task.configuration.SimpleTaskAutoConfiguration 3 | org.springframework.cloud.task.configuration.observation.ObservationTaskAutoConfiguration 4 | -------------------------------------------------------------------------------- /spring-cloud-task-core/src/main/resources/org/springframework/cloud/task/migration/1.1.x/migration-h2.sql: -------------------------------------------------------------------------------- 1 | /* If migrating from 1.1.0.M1 to 1.1.0.RELEASE you do not need to add 2 | the ERROR_MESSAGE column. */ 3 | alter table TASK_EXECUTION add ERROR_MESSAGE VARCHAR(2500); 4 | alter table TASK_EXECUTION add EXTERNAL_EXECUTION_ID VARCHAR(255); 5 | -------------------------------------------------------------------------------- /spring-cloud-task-core/src/main/resources/org/springframework/cloud/task/migration/1.1.x/migration-hsqldb.sql: -------------------------------------------------------------------------------- 1 | /* If migrating from 1.1.0.M1 to 1.1.0.RELEASE you do not need to add 2 | the ERROR_MESSAGE column. */ 3 | alter table TASK_EXECUTION add ERROR_MESSAGE VARCHAR(2500); 4 | alter table TASK_EXECUTION add EXTERNAL_EXECUTION_ID VARCHAR(255); 5 | -------------------------------------------------------------------------------- /spring-cloud-task-core/src/main/resources/org/springframework/cloud/task/migration/1.1.x/migration-mysql.sql: -------------------------------------------------------------------------------- 1 | /* If migrating from 1.1.0.M1 to 1.1.0.RELEASE you do not need to add 2 | the ERROR_MESSAGE column. */ 3 | alter table TASK_EXECUTION add ERROR_MESSAGE VARCHAR(2500); 4 | alter table TASK_EXECUTION add EXTERNAL_EXECUTION_ID VARCHAR(255); 5 | 6 | -------------------------------------------------------------------------------- /spring-cloud-task-core/src/main/resources/org/springframework/cloud/task/migration/1.1.x/migration-oracle.sql: -------------------------------------------------------------------------------- 1 | /* If migrating from 1.1.0.M1 to 1.1.0.RELEASE you do not need to add 2 | the ERROR_MESSAGE column. */ 3 | alter table TASK_EXECUTION add ERROR_MESSAGE varchar2(2500); 4 | alter table TASK_EXECUTION add EXTERNAL_EXECUTION_ID varchar2(255); 5 | 6 | -------------------------------------------------------------------------------- /spring-cloud-task-core/src/main/resources/org/springframework/cloud/task/migration/1.1.x/migration-postgresql.sql: -------------------------------------------------------------------------------- 1 | /* If migrating from 1.1.0.M1 to 1.1.0.RELEASE you do not need to add 2 | the ERROR_MESSAGE column. */ 3 | alter table TASK_EXECUTION add ERROR_MESSAGE VARCHAR(2500); 4 | alter table TASK_EXECUTION add EXTERNAL_EXECUTION_ID VARCHAR(255); 5 | -------------------------------------------------------------------------------- /spring-cloud-task-core/src/main/resources/org/springframework/cloud/task/migration/1.1.x/migration-sqlserver.sql: -------------------------------------------------------------------------------- 1 | /* If migrating from 1.1.0.M1 to 1.1.0.RELEASE you do not need to add 2 | the ERROR_MESSAGE column. */ 3 | alter table TASK_EXECUTION add ERROR_MESSAGE VARCHAR(2500); 4 | alter table TASK_EXECUTION add EXTERNAL_EXECUTION_ID VARCHAR(255); 5 | -------------------------------------------------------------------------------- /spring-cloud-task-core/src/main/resources/org/springframework/cloud/task/migration/1.2.x/migration-db2.sql: -------------------------------------------------------------------------------- 1 | alter table TASK_EXECUTION add PARENT_EXECUTION_ID BIGINT; 2 | -------------------------------------------------------------------------------- /spring-cloud-task-core/src/main/resources/org/springframework/cloud/task/migration/1.2.x/migration-h2.sql: -------------------------------------------------------------------------------- 1 | alter table TASK_EXECUTION add PARENT_EXECUTION_ID BIGINT; 2 | -------------------------------------------------------------------------------- /spring-cloud-task-core/src/main/resources/org/springframework/cloud/task/migration/1.2.x/migration-hsqldb.sql: -------------------------------------------------------------------------------- 1 | alter table TASK_EXECUTION add PARENT_EXECUTION_ID BIGINT; 2 | -------------------------------------------------------------------------------- /spring-cloud-task-core/src/main/resources/org/springframework/cloud/task/migration/1.2.x/migration-mysql.sql: -------------------------------------------------------------------------------- 1 | alter table TASK_EXECUTION add PARENT_EXECUTION_ID BIGINT; 2 | -------------------------------------------------------------------------------- /spring-cloud-task-core/src/main/resources/org/springframework/cloud/task/migration/1.2.x/migration-oracle.sql: -------------------------------------------------------------------------------- 1 | alter table TASK_EXECUTION add PARENT_EXECUTION_ID NUMBER; 2 | -------------------------------------------------------------------------------- /spring-cloud-task-core/src/main/resources/org/springframework/cloud/task/migration/1.2.x/migration-postgresql.sql: -------------------------------------------------------------------------------- 1 | alter table TASK_EXECUTION add PARENT_EXECUTION_ID BIGINT; 2 | -------------------------------------------------------------------------------- /spring-cloud-task-core/src/main/resources/org/springframework/cloud/task/migration/1.2.x/migration-sqlserver.sql: -------------------------------------------------------------------------------- 1 | alter table TASK_EXECUTION add PARENT_EXECUTION_ID BIGINT; 2 | -------------------------------------------------------------------------------- /spring-cloud-task-core/src/main/resources/org/springframework/cloud/task/migration/2.2.x/migration-oracle.sql: -------------------------------------------------------------------------------- 1 | alter table TASK_LOCK MODIFY LOCK_KEY VARCHAR2(36); 2 | alter table TASK_LOCK MODIFY CLIENT_ID VARCHAR2(36); 3 | -------------------------------------------------------------------------------- /spring-cloud-task-core/src/main/resources/org/springframework/cloud/task/migration/3.0.x/migration-db2.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE TASK_EXECUTION ALTER COLUMN START_TIME SET DATA TYPE TIMESTAMP(9); 2 | ALTER TABLE TASK_EXECUTION ALTER COLUMN END_TIME SET DATA TYPE TIMESTAMP(9); 3 | ALTER TABLE TASK_EXECUTION ALTER COLUMN LAST_UPDATED SET DATA TYPE TIMESTAMP(9); 4 | ALTER TABLE TASK_LOCK ALTER COLUMN CREATED_DATE SET DATA TYPE TIMESTAMP(9); 5 | 6 | -------------------------------------------------------------------------------- /spring-cloud-task-core/src/main/resources/org/springframework/cloud/task/migration/3.0.x/migration-h2.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE TASK_EXECUTION ALTER COLUMN START_TIME SET DATA TYPE TIMESTAMP(9); 2 | ALTER TABLE TASK_EXECUTION ALTER COLUMN END_TIME SET DATA TYPE TIMESTAMP(9); 3 | ALTER TABLE TASK_EXECUTION ALTER COLUMN LAST_UPDATED SET DATA TYPE TIMESTAMP(9); 4 | ALTER TABLE TASK_LOCK ALTER COLUMN CREATED_DATE SET DATA TYPE TIMESTAMP(9); 5 | -------------------------------------------------------------------------------- /spring-cloud-task-core/src/main/resources/org/springframework/cloud/task/migration/3.0.x/migration-hsqldb.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE TASK_EXECUTION ALTER COLUMN START_TIME SET DATA TYPE TIMESTAMP(9); 2 | ALTER TABLE TASK_EXECUTION ALTER COLUMN END_TIME SET DATA TYPE TIMESTAMP(9); 3 | ALTER TABLE TASK_EXECUTION ALTER COLUMN LAST_UPDATED SET DATA TYPE TIMESTAMP(9); 4 | ALTER TABLE TASK_LOCK ALTER COLUMN CREATED_DATE SET DATA TYPE TIMESTAMP(9); 5 | -------------------------------------------------------------------------------- /spring-cloud-task-core/src/main/resources/org/springframework/cloud/task/migration/3.0.x/migration-mysql.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE TASK_EXECUTION MODIFY COLUMN END_TIME DATETIME(6) NULL; 2 | ALTER TABLE TASK_EXECUTION MODIFY COLUMN START_TIME DATETIME(6) NULL; 3 | ALTER TABLE TASK_EXECUTION MODIFY COLUMN LAST_UPDATED DATETIME(6) NULL; 4 | ALTER TABLE TASK_LOCK MODIFY COLUMN CREATED_DATE DATETIME(6) NULL; 5 | -------------------------------------------------------------------------------- /spring-cloud-task-core/src/main/resources/org/springframework/cloud/task/migration/3.0.x/migration-oracle.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE TASK_EXECUTION MODIFY COLUMN CREATE_TIME TIMESTAMP(9); 2 | ALTER TABLE TASK_EXECUTION MODIFY COLUMN START_TIME TIMESTAMP(9); 3 | ALTER TABLE TASK_EXECUTION MODIFY COLUMN LAST_UPDATED TIMESTAMP(9); 4 | ALTER TABLE TASK_LOCK MODIFY COLUMN CREATED_DATE TIMESTAMP(9); 5 | 6 | 7 | ALTER SEQUENCE TASK_SEQ ORDER; 8 | -------------------------------------------------------------------------------- /spring-cloud-task-core/src/main/resources/org/springframework/cloud/task/schema-db2.sql: -------------------------------------------------------------------------------- 1 | 2 | CREATE TABLE TASK_EXECUTION ( 3 | TASK_EXECUTION_ID BIGINT NOT NULL PRIMARY KEY , 4 | START_TIME TIMESTAMP(9) DEFAULT NULL , 5 | END_TIME TIMESTAMP(9) DEFAULT NULL , 6 | TASK_NAME VARCHAR(100) , 7 | EXIT_CODE INTEGER , 8 | EXIT_MESSAGE VARCHAR(2500) , 9 | ERROR_MESSAGE VARCHAR(2500) , 10 | LAST_UPDATED TIMESTAMP(9), 11 | EXTERNAL_EXECUTION_ID VARCHAR(255), 12 | PARENT_EXECUTION_ID BIGINT 13 | ); 14 | 15 | CREATE TABLE TASK_EXECUTION_PARAMS ( 16 | TASK_EXECUTION_ID BIGINT NOT NULL , 17 | TASK_PARAM VARCHAR(2500) , 18 | constraint TASK_EXEC_PARAMS_FK foreign key (TASK_EXECUTION_ID) 19 | references TASK_EXECUTION(TASK_EXECUTION_ID) 20 | ) ; 21 | 22 | CREATE TABLE TASK_TASK_BATCH ( 23 | TASK_EXECUTION_ID BIGINT NOT NULL , 24 | JOB_EXECUTION_ID BIGINT NOT NULL , 25 | constraint TASK_EXEC_BATCH_FK foreign key (TASK_EXECUTION_ID) 26 | references TASK_EXECUTION(TASK_EXECUTION_ID) 27 | ) ; 28 | 29 | CREATE SEQUENCE TASK_SEQ AS BIGINT START WITH 0 MINVALUE 0 MAXVALUE 9223372036854775807 NOCACHE NOCYCLE; 30 | 31 | CREATE TABLE TASK_LOCK ( 32 | LOCK_KEY CHAR(36) NOT NULL, 33 | REGION VARCHAR(100) NOT NULL, 34 | CLIENT_ID CHAR(36), 35 | CREATED_DATE TIMESTAMP(9) NOT NULL, 36 | constraint LOCK_PK primary key (LOCK_KEY, REGION) 37 | ); 38 | -------------------------------------------------------------------------------- /spring-cloud-task-core/src/main/resources/org/springframework/cloud/task/schema-h2.sql: -------------------------------------------------------------------------------- 1 | 2 | CREATE TABLE TASK_EXECUTION ( 3 | TASK_EXECUTION_ID BIGINT NOT NULL PRIMARY KEY , 4 | START_TIME TIMESTAMP(9) DEFAULT NULL , 5 | END_TIME TIMESTAMP(9) DEFAULT NULL , 6 | TASK_NAME VARCHAR(100) , 7 | EXIT_CODE INTEGER , 8 | EXIT_MESSAGE VARCHAR(2500) , 9 | ERROR_MESSAGE VARCHAR(2500) , 10 | LAST_UPDATED TIMESTAMP(9), 11 | EXTERNAL_EXECUTION_ID VARCHAR(255), 12 | PARENT_EXECUTION_ID BIGINT 13 | ); 14 | 15 | CREATE TABLE TASK_EXECUTION_PARAMS ( 16 | TASK_EXECUTION_ID BIGINT NOT NULL , 17 | TASK_PARAM VARCHAR(2500) , 18 | constraint TASK_EXEC_PARAMS_FK foreign key (TASK_EXECUTION_ID) 19 | references TASK_EXECUTION(TASK_EXECUTION_ID) 20 | ) ; 21 | 22 | CREATE TABLE TASK_TASK_BATCH ( 23 | TASK_EXECUTION_ID BIGINT NOT NULL , 24 | JOB_EXECUTION_ID BIGINT NOT NULL , 25 | constraint TASK_EXEC_BATCH_FK foreign key (TASK_EXECUTION_ID) 26 | references TASK_EXECUTION(TASK_EXECUTION_ID) 27 | ) ; 28 | 29 | CREATE SEQUENCE TASK_SEQ ; 30 | 31 | CREATE TABLE TASK_LOCK ( 32 | LOCK_KEY CHAR(36) NOT NULL, 33 | REGION VARCHAR(100) NOT NULL, 34 | CLIENT_ID CHAR(36), 35 | CREATED_DATE TIMESTAMP(9) NOT NULL, 36 | constraint LOCK_PK primary key (LOCK_KEY, REGION) 37 | ); 38 | -------------------------------------------------------------------------------- /spring-cloud-task-core/src/main/resources/org/springframework/cloud/task/schema-hsqldb.sql: -------------------------------------------------------------------------------- 1 | 2 | CREATE TABLE TASK_EXECUTION ( 3 | TASK_EXECUTION_ID BIGINT NOT NULL PRIMARY KEY , 4 | START_TIME TIMESTAMP(9) DEFAULT NULL , 5 | END_TIME TIMESTAMP(9) DEFAULT NULL , 6 | TASK_NAME VARCHAR(100) , 7 | EXIT_CODE INTEGER , 8 | EXIT_MESSAGE VARCHAR(2500) , 9 | ERROR_MESSAGE VARCHAR(2500) , 10 | LAST_UPDATED TIMESTAMP(9), 11 | EXTERNAL_EXECUTION_ID VARCHAR(255), 12 | PARENT_EXECUTION_ID BIGINT 13 | ); 14 | 15 | CREATE TABLE TASK_EXECUTION_PARAMS ( 16 | TASK_EXECUTION_ID BIGINT NOT NULL , 17 | TASK_PARAM VARCHAR(2500) , 18 | constraint TASK_EXEC_PARAMS_FK foreign key (TASK_EXECUTION_ID) 19 | references TASK_EXECUTION(TASK_EXECUTION_ID) 20 | ) ; 21 | 22 | CREATE TABLE TASK_TASK_BATCH ( 23 | TASK_EXECUTION_ID BIGINT NOT NULL , 24 | JOB_EXECUTION_ID BIGINT NOT NULL , 25 | constraint TASK_EXEC_BATCH_FK foreign key (TASK_EXECUTION_ID) 26 | references TASK_EXECUTION(TASK_EXECUTION_ID) 27 | ) ; 28 | 29 | CREATE TABLE TASK_SEQ ( 30 | ID BIGINT IDENTITY 31 | ); 32 | 33 | CREATE TABLE TASK_LOCK ( 34 | LOCK_KEY CHAR(36) NOT NULL, 35 | REGION VARCHAR(100) NOT NULL, 36 | CLIENT_ID CHAR(36), 37 | CREATED_DATE TIMESTAMP(9) NOT NULL, 38 | constraint LOCK_PK primary key (LOCK_KEY, REGION) 39 | ); 40 | -------------------------------------------------------------------------------- /spring-cloud-task-core/src/main/resources/org/springframework/cloud/task/schema-mariadb.sql: -------------------------------------------------------------------------------- 1 | 2 | CREATE TABLE TASK_EXECUTION ( 3 | TASK_EXECUTION_ID BIGINT NOT NULL PRIMARY KEY , 4 | START_TIME DATETIME(6) DEFAULT NULL , 5 | END_TIME DATETIME(6) DEFAULT NULL , 6 | TASK_NAME VARCHAR(100) , 7 | EXIT_CODE INTEGER , 8 | EXIT_MESSAGE VARCHAR(2500) , 9 | ERROR_MESSAGE VARCHAR(2500) , 10 | LAST_UPDATED TIMESTAMP, 11 | EXTERNAL_EXECUTION_ID VARCHAR(255), 12 | PARENT_EXECUTION_ID BIGINT 13 | ) ENGINE=InnoDB; 14 | 15 | CREATE TABLE TASK_EXECUTION_PARAMS ( 16 | TASK_EXECUTION_ID BIGINT NOT NULL , 17 | TASK_PARAM VARCHAR(2500) , 18 | constraint TASK_EXEC_PARAMS_FK foreign key (TASK_EXECUTION_ID) 19 | references TASK_EXECUTION(TASK_EXECUTION_ID) 20 | ) ENGINE=InnoDB; 21 | 22 | CREATE TABLE TASK_TASK_BATCH ( 23 | TASK_EXECUTION_ID BIGINT NOT NULL , 24 | JOB_EXECUTION_ID BIGINT NOT NULL , 25 | constraint TASK_EXEC_BATCH_FK foreign key (TASK_EXECUTION_ID) 26 | references TASK_EXECUTION(TASK_EXECUTION_ID) 27 | ) ENGINE=InnoDB; 28 | 29 | CREATE TABLE TASK_LOCK ( 30 | LOCK_KEY CHAR(36) NOT NULL, 31 | REGION VARCHAR(100) NOT NULL, 32 | CLIENT_ID CHAR(36), 33 | CREATED_DATE DATETIME(6) NOT NULL, 34 | constraint LOCK_PK primary key (LOCK_KEY, REGION) 35 | ) ENGINE=InnoDB; 36 | 37 | CREATE SEQUENCE TASK_SEQ START WITH 1 MINVALUE 1 MAXVALUE 9223372036854775806 INCREMENT BY 1 NOCACHE NOCYCLE ENGINE=InnoDB; 38 | -------------------------------------------------------------------------------- /spring-cloud-task-core/src/main/resources/org/springframework/cloud/task/schema-mysql.sql: -------------------------------------------------------------------------------- 1 | 2 | CREATE TABLE TASK_EXECUTION ( 3 | TASK_EXECUTION_ID BIGINT NOT NULL PRIMARY KEY , 4 | START_TIME DATETIME(6) DEFAULT NULL , 5 | END_TIME DATETIME(6) DEFAULT NULL , 6 | TASK_NAME VARCHAR(100) , 7 | EXIT_CODE INTEGER , 8 | EXIT_MESSAGE VARCHAR(2500) , 9 | ERROR_MESSAGE VARCHAR(2500) , 10 | LAST_UPDATED TIMESTAMP, 11 | EXTERNAL_EXECUTION_ID VARCHAR(255), 12 | PARENT_EXECUTION_ID BIGINT 13 | ) ENGINE=InnoDB; 14 | 15 | CREATE TABLE TASK_EXECUTION_PARAMS ( 16 | TASK_EXECUTION_ID BIGINT NOT NULL , 17 | TASK_PARAM VARCHAR(2500) , 18 | constraint TASK_EXEC_PARAMS_FK foreign key (TASK_EXECUTION_ID) 19 | references TASK_EXECUTION(TASK_EXECUTION_ID) 20 | ) ENGINE=InnoDB; 21 | 22 | CREATE TABLE TASK_TASK_BATCH ( 23 | TASK_EXECUTION_ID BIGINT NOT NULL , 24 | JOB_EXECUTION_ID BIGINT NOT NULL , 25 | constraint TASK_EXEC_BATCH_FK foreign key (TASK_EXECUTION_ID) 26 | references TASK_EXECUTION(TASK_EXECUTION_ID) 27 | ) ENGINE=InnoDB; 28 | 29 | CREATE TABLE TASK_SEQ ( 30 | ID BIGINT NOT NULL, 31 | UNIQUE_KEY CHAR(1) NOT NULL, 32 | constraint UNIQUE_KEY_UN unique (UNIQUE_KEY) 33 | ) ENGINE=InnoDB; 34 | 35 | INSERT INTO TASK_SEQ (ID, UNIQUE_KEY) select * from (select 0 as ID, '0' as UNIQUE_KEY) as tmp; 36 | 37 | CREATE TABLE TASK_LOCK ( 38 | LOCK_KEY CHAR(36) NOT NULL, 39 | REGION VARCHAR(100) NOT NULL, 40 | CLIENT_ID CHAR(36), 41 | CREATED_DATE DATETIME(6) NOT NULL, 42 | constraint LOCK_PK primary key (LOCK_KEY, REGION) 43 | ) ENGINE=InnoDB; 44 | -------------------------------------------------------------------------------- /spring-cloud-task-core/src/main/resources/org/springframework/cloud/task/schema-oracle.sql: -------------------------------------------------------------------------------- 1 | 2 | CREATE TABLE TASK_EXECUTION ( 3 | TASK_EXECUTION_ID NUMBER NOT NULL PRIMARY KEY , 4 | START_TIME TIMESTAMP(9) DEFAULT NULL , 5 | END_TIME TIMESTAMP(9) DEFAULT NULL , 6 | TASK_NAME VARCHAR2(100) , 7 | EXIT_CODE INTEGER , 8 | EXIT_MESSAGE VARCHAR2(2500) , 9 | ERROR_MESSAGE VARCHAR2(2500) , 10 | LAST_UPDATED TIMESTAMP(9), 11 | EXTERNAL_EXECUTION_ID VARCHAR2(255), 12 | PARENT_EXECUTION_ID NUMBER 13 | ); 14 | 15 | CREATE TABLE TASK_EXECUTION_PARAMS ( 16 | TASK_EXECUTION_ID NUMBER NOT NULL , 17 | TASK_PARAM VARCHAR2(2500) , 18 | constraint TASK_EXEC_PARAMS_FK foreign key (TASK_EXECUTION_ID) 19 | references TASK_EXECUTION(TASK_EXECUTION_ID) 20 | ) ; 21 | 22 | CREATE TABLE TASK_TASK_BATCH ( 23 | TASK_EXECUTION_ID NUMBER NOT NULL , 24 | JOB_EXECUTION_ID NUMBER NOT NULL , 25 | constraint TASK_EXEC_BATCH_FK foreign key (TASK_EXECUTION_ID) 26 | references TASK_EXECUTION(TASK_EXECUTION_ID) 27 | ) ; 28 | 29 | CREATE SEQUENCE TASK_SEQ START WITH 0 MINVALUE 0 MAXVALUE 9223372036854775807 ORDER NOCYCLE; 30 | 31 | CREATE TABLE TASK_LOCK ( 32 | LOCK_KEY VARCHAR2(36) NOT NULL, 33 | REGION VARCHAR2(100) NOT NULL, 34 | CLIENT_ID VARCHAR2(36), 35 | CREATED_DATE TIMESTAMP(9) NOT NULL, 36 | constraint LOCK_PK primary key (LOCK_KEY, REGION) 37 | ); 38 | -------------------------------------------------------------------------------- /spring-cloud-task-core/src/main/resources/org/springframework/cloud/task/schema-postgresql.sql: -------------------------------------------------------------------------------- 1 | 2 | CREATE TABLE TASK_EXECUTION ( 3 | TASK_EXECUTION_ID BIGINT NOT NULL PRIMARY KEY , 4 | START_TIME TIMESTAMP DEFAULT NULL , 5 | END_TIME TIMESTAMP DEFAULT NULL , 6 | TASK_NAME VARCHAR(100) , 7 | EXIT_CODE INTEGER , 8 | EXIT_MESSAGE VARCHAR(2500) , 9 | ERROR_MESSAGE VARCHAR(2500) , 10 | LAST_UPDATED TIMESTAMP , 11 | EXTERNAL_EXECUTION_ID VARCHAR(255), 12 | PARENT_EXECUTION_ID BIGINT 13 | ); 14 | 15 | CREATE TABLE TASK_EXECUTION_PARAMS ( 16 | TASK_EXECUTION_ID BIGINT NOT NULL , 17 | TASK_PARAM VARCHAR(2500) , 18 | constraint TASK_EXEC_PARAMS_FK foreign key (TASK_EXECUTION_ID) 19 | references TASK_EXECUTION(TASK_EXECUTION_ID) 20 | ) ; 21 | 22 | CREATE TABLE TASK_TASK_BATCH ( 23 | TASK_EXECUTION_ID BIGINT NOT NULL , 24 | JOB_EXECUTION_ID BIGINT NOT NULL , 25 | constraint TASK_EXEC_BATCH_FK foreign key (TASK_EXECUTION_ID) 26 | references TASK_EXECUTION(TASK_EXECUTION_ID) 27 | ) ; 28 | 29 | CREATE SEQUENCE TASK_SEQ MAXVALUE 9223372036854775807 NO CYCLE; 30 | 31 | CREATE TABLE TASK_LOCK ( 32 | LOCK_KEY CHAR(36) NOT NULL, 33 | REGION VARCHAR(100) NOT NULL, 34 | CLIENT_ID CHAR(36), 35 | CREATED_DATE TIMESTAMP NOT NULL, 36 | constraint LOCK_PK primary key (LOCK_KEY, REGION) 37 | ); 38 | -------------------------------------------------------------------------------- /spring-cloud-task-core/src/main/resources/org/springframework/cloud/task/schema-sqlserver.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE TASK_EXECUTION ( 2 | TASK_EXECUTION_ID BIGINT NOT NULL PRIMARY KEY , 3 | START_TIME DATETIME DEFAULT NULL , 4 | END_TIME DATETIME DEFAULT NULL , 5 | TASK_NAME VARCHAR(100) , 6 | EXIT_CODE INTEGER , 7 | EXIT_MESSAGE VARCHAR(2500) , 8 | ERROR_MESSAGE VARCHAR(2500) , 9 | LAST_UPDATED DATETIME , 10 | EXTERNAL_EXECUTION_ID VARCHAR(255), 11 | PARENT_EXECUTION_ID BIGINT 12 | ); 13 | 14 | CREATE TABLE TASK_EXECUTION_PARAMS ( 15 | TASK_EXECUTION_ID BIGINT NOT NULL , 16 | TASK_PARAM VARCHAR(2500) , 17 | constraint TASK_EXEC_PARAMS_FK foreign key (TASK_EXECUTION_ID) 18 | references TASK_EXECUTION(TASK_EXECUTION_ID) 19 | ) ; 20 | 21 | CREATE TABLE TASK_TASK_BATCH ( 22 | TASK_EXECUTION_ID BIGINT NOT NULL , 23 | JOB_EXECUTION_ID BIGINT NOT NULL , 24 | constraint TASK_EXEC_BATCH_FK foreign key (TASK_EXECUTION_ID) 25 | references TASK_EXECUTION(TASK_EXECUTION_ID) 26 | ) ; 27 | 28 | CREATE SEQUENCE TASK_SEQ START WITH 0 MINVALUE 0 MAXVALUE 9223372036854775807 NO CACHE NO CYCLE; 29 | 30 | CREATE TABLE TASK_LOCK ( 31 | LOCK_KEY CHAR(36) NOT NULL, 32 | REGION VARCHAR(100) NOT NULL, 33 | CLIENT_ID CHAR(36), 34 | CREATED_DATE DATETIME NOT NULL, 35 | constraint LOCK_PK primary key (LOCK_KEY, REGION) 36 | ); 37 | -------------------------------------------------------------------------------- /spring-cloud-task-core/src/test/java/org/springframework/cloud/task/configuration/TaskPropertiesTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.cloud.task.configuration; 18 | 19 | import org.junit.jupiter.api.Test; 20 | import org.junit.jupiter.api.extension.ExtendWith; 21 | 22 | import org.springframework.beans.factory.annotation.Autowired; 23 | import org.springframework.boot.test.context.SpringBootTest; 24 | import org.springframework.test.annotation.DirtiesContext; 25 | import org.springframework.test.context.junit.jupiter.SpringExtension; 26 | 27 | import static org.assertj.core.api.Assertions.assertThat; 28 | 29 | @DirtiesContext 30 | @ExtendWith(SpringExtension.class) 31 | @SpringBootTest(classes = { SimpleTaskAutoConfiguration.class, SingleTaskConfiguration.class }, 32 | properties = { "spring.cloud.task.closecontextEnabled=false", "spring.cloud.task.initialize-enabled=false" }) 33 | public class TaskPropertiesTests { 34 | 35 | @Autowired 36 | TaskProperties taskProperties; 37 | 38 | @Test 39 | public void test() { 40 | assertThat(this.taskProperties.getClosecontextEnabled()).isFalse(); 41 | assertThat(this.taskProperties.isInitializeEnabled()).isFalse(); 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /spring-cloud-task-core/src/test/java/org/springframework/cloud/task/listener/TaskExceptionTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.cloud.task.listener; 18 | 19 | import org.junit.jupiter.api.Test; 20 | 21 | import static org.assertj.core.api.Assertions.assertThat; 22 | 23 | /** 24 | * @author Glenn Renfro 25 | */ 26 | public class TaskExceptionTests { 27 | 28 | private static final String ERROR_MESSAGE = "ERROR MESSAGE"; 29 | 30 | @Test 31 | public void testTaskException() { 32 | TaskException taskException = new TaskException(ERROR_MESSAGE); 33 | assertThat(taskException.getMessage()).isEqualTo(ERROR_MESSAGE); 34 | 35 | taskException = new TaskException(ERROR_MESSAGE, new IllegalStateException(ERROR_MESSAGE)); 36 | assertThat(taskException.getMessage()).isEqualTo(ERROR_MESSAGE); 37 | assertThat(taskException.getCause()).isNotNull(); 38 | assertThat(taskException.getCause().getMessage()).isEqualTo(ERROR_MESSAGE); 39 | } 40 | 41 | @Test 42 | public void testTaskExecutionException() { 43 | TaskExecutionException taskException = new TaskExecutionException(ERROR_MESSAGE); 44 | assertThat(taskException.getMessage()).isEqualTo(ERROR_MESSAGE); 45 | 46 | taskException = new TaskExecutionException(ERROR_MESSAGE, new IllegalStateException(ERROR_MESSAGE)); 47 | assertThat(taskException.getMessage()).isEqualTo(ERROR_MESSAGE); 48 | assertThat(taskException.getCause()).isNotNull(); 49 | assertThat(taskException.getCause().getMessage()).isEqualTo(ERROR_MESSAGE); 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /spring-cloud-task-core/src/test/java/org/springframework/cloud/task/repository/database/support/InvalidPagingQueryProviderTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.cloud.task.repository.database.support; 18 | 19 | import org.junit.jupiter.api.Test; 20 | 21 | import org.springframework.cloud.task.util.TestDBUtils; 22 | import org.springframework.data.domain.PageRequest; 23 | import org.springframework.data.domain.Pageable; 24 | 25 | import static org.assertj.core.api.Assertions.assertThatExceptionOfType; 26 | 27 | /** 28 | * @author Glenn Renfro 29 | */ 30 | public class InvalidPagingQueryProviderTests { 31 | 32 | @Test 33 | public void testInvalidDatabase() throws Exception { 34 | Pageable pageable = PageRequest.of(0, 10); 35 | assertThatExceptionOfType(IllegalStateException.class).isThrownBy(() -> { 36 | TestDBUtils.getPagingQueryProvider("Invalid").getPageQuery(pageable); 37 | }); 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /spring-cloud-task-core/src/test/resources/application.properties: -------------------------------------------------------------------------------- 1 | logging.level.org.springframework.cloud.task=debug 2 | -------------------------------------------------------------------------------- /spring-cloud-task-core/src/test/resources/micrometer/pcf-scs-info.json: -------------------------------------------------------------------------------- 1 | { 2 | "sso":[{ 3 | "name": "sso", 4 | "label": "sso", 5 | "plan": "notfree", 6 | "tags": ["configuration"], 7 | "credentials":{ 8 | "uri": "https://pivotal.io", 9 | "client_id": "fakeClientId", 10 | "client_secret": "fakeSecret", 11 | "access_token_uri": "token" 12 | } 13 | }]} 14 | -------------------------------------------------------------------------------- /spring-cloud-task-integration-tests/src/test/java/configuration/SkipItemReader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package configuration; 18 | 19 | import org.springframework.batch.item.ItemReader; 20 | import org.springframework.batch.item.NonTransientResourceException; 21 | import org.springframework.batch.item.ParseException; 22 | import org.springframework.batch.item.UnexpectedInputException; 23 | 24 | /** 25 | * @author Glenn Renfro 26 | */ 27 | public class SkipItemReader implements ItemReader { 28 | 29 | int failCount = 0; 30 | 31 | boolean finished = false; 32 | 33 | @Override 34 | public Object read() throws Exception, UnexpectedInputException, ParseException, NonTransientResourceException { 35 | String result = "1"; 36 | if (this.failCount < 2) { 37 | this.failCount++; 38 | throw new IllegalStateException("Reader FOOBAR"); 39 | } 40 | if (this.finished) { 41 | result = null; 42 | } 43 | this.finished = true; 44 | return result; 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /spring-cloud-task-integration-tests/src/test/java/configuration/SkipItemWriter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package configuration; 18 | 19 | import org.springframework.batch.item.Chunk; 20 | import org.springframework.batch.item.ItemWriter; 21 | 22 | /** 23 | * @author Glenn Renfro 24 | */ 25 | public class SkipItemWriter implements ItemWriter { 26 | 27 | int failCount = 0; 28 | 29 | @Override 30 | public void write(Chunk items) throws Exception { 31 | if (this.failCount < 2) { 32 | this.failCount++; 33 | throw new IllegalStateException("Writer FOOBAR"); 34 | } 35 | for (Object item : items) { 36 | System.out.println(">> " + item); 37 | } 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /spring-cloud-task-integration-tests/src/test/java/org/springframework/cloud/task/executionid/TaskStartApplication.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.cloud.task.executionid; 18 | 19 | import org.springframework.boot.CommandLineRunner; 20 | import org.springframework.boot.SpringApplication; 21 | import org.springframework.boot.autoconfigure.SpringBootApplication; 22 | import org.springframework.cloud.task.configuration.EnableTask; 23 | import org.springframework.context.annotation.Bean; 24 | 25 | /** 26 | * @author Glenn Renfro 27 | */ 28 | @EnableTask 29 | @SpringBootApplication 30 | public class TaskStartApplication { 31 | 32 | public static void main(String[] args) { 33 | SpringApplication.run(TaskStartApplication.class, args); 34 | } 35 | 36 | @Bean 37 | public CommandLineRunner testCommandLineRunner() { 38 | return new CommandLineRunner() { 39 | @Override 40 | public void run(String... strings) throws Exception { 41 | for (String s : strings) { 42 | System.out.println("Test" + s); 43 | } 44 | } 45 | }; 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /spring-cloud-task-integration-tests/src/test/java/org/springframework/cloud/task/launcher/app/TaskLauncherSinkApplication.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.cloud.task.launcher.app; 18 | 19 | import org.springframework.boot.SpringApplication; 20 | import org.springframework.boot.autoconfigure.SpringBootApplication; 21 | import org.springframework.cloud.task.launcher.annotation.EnableTaskLauncher; 22 | 23 | /** 24 | * @author Glenn Renfro 25 | */ 26 | // @checkstyle:off 27 | @SpringBootApplication 28 | @EnableTaskLauncher 29 | public class TaskLauncherSinkApplication { 30 | 31 | public static void main(String[] args) { 32 | SpringApplication.run(TaskLauncherSinkApplication.class, args); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /spring-cloud-task-integration-tests/src/test/resources/application.properties: -------------------------------------------------------------------------------- 1 | logging.level.org.springframework.cloud.task=DEBUG 2 | logging.level.org.springframework.cloud.stream=DEBUG 3 | spring.application.name=batchEvents 4 | -------------------------------------------------------------------------------- /spring-cloud-task-integration-tests/src/test/resources/org/springframework/cloud/task/listener/chunk-events-sink-channel.properties: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2016-2019 the original author or authors. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # https://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | spring.cloud.stream.bindings.input.destination=chunk-events-foobar 17 | -------------------------------------------------------------------------------- /spring-cloud-task-integration-tests/src/test/resources/org/springframework/cloud/task/listener/item-process-sink-channel.properties: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2016-2019 the original author or authors. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # https://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | spring.cloud.stream.bindings.input.destination=item-process-foobar 17 | -------------------------------------------------------------------------------- /spring-cloud-task-integration-tests/src/test/resources/org/springframework/cloud/task/listener/item-read-events-sink-channel.properties: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2016-2019 the original author or authors. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # https://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | spring.cloud.stream.bindings.input.destination=item-read-events-foobar 17 | -------------------------------------------------------------------------------- /spring-cloud-task-integration-tests/src/test/resources/org/springframework/cloud/task/listener/item-write-events-sink-channel.properties: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2016-2019 the original author or authors. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # https://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | spring.cloud.stream.bindings.input.destination=item-write-events-foobar 17 | -------------------------------------------------------------------------------- /spring-cloud-task-integration-tests/src/test/resources/org/springframework/cloud/task/listener/job-execution-sink-channel.properties: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2016-2019 the original author or authors. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # https://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | spring.cloud.stream.bindings.input.destination=foobar 17 | -------------------------------------------------------------------------------- /spring-cloud-task-integration-tests/src/test/resources/org/springframework/cloud/task/listener/sink-channel.properties: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2016-2019 the original author or authors. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # https://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | spring.cloud.stream.bindings.input.destination=test 17 | -------------------------------------------------------------------------------- /spring-cloud-task-integration-tests/src/test/resources/org/springframework/cloud/task/listener/skip-events-sink-channel.properties: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2016-2019 the original author or authors. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # https://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | spring.cloud.stream.bindings.input.destination=skip-event-foobar 17 | -------------------------------------------------------------------------------- /spring-cloud-task-integration-tests/src/test/resources/org/springframework/cloud/task/listener/step-execution-sink-channel.properties: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2016-2019 the original author or authors. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # https://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | spring.cloud.stream.bindings.input.destination=step-execution-foobar 17 | -------------------------------------------------------------------------------- /spring-cloud-task-samples/batch-events/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spring-cloud/spring-cloud-task/b9dfa48bb3b4970f68008340a28d31dfb79b8ea5/spring-cloud-task-samples/batch-events/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /spring-cloud-task-samples/batch-events/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip 2 | -------------------------------------------------------------------------------- /spring-cloud-task-samples/batch-events/README.adoc: -------------------------------------------------------------------------------- 1 | = Task Events 2 | 3 | This is a task application that emits batch job events to the following channels: 4 | 5 | * job-execution-events 6 | * step-execution-events 7 | * chunk-events 8 | * item-read-events 9 | * item-process-events 10 | * item-write-events 11 | * skip-events 12 | 13 | Note: More information on this topic is available https://docs.spring.io/spring-cloud-task/docs/current/reference/html/#stream-integration-batch-events[here]. 14 | 15 | == Requirements: 16 | 17 | * Java 17 or Above 18 | 19 | == Build: 20 | 21 | [source,shell] 22 | ---- 23 | ./mvnw clean install 24 | ---- 25 | 26 | == Execution: 27 | 28 | [source,shell] 29 | ---- 30 | java -jar target/batch-events-3.0.0.jar 31 | ---- 32 | 33 | For example, you can listen for specific job-execution events on a specified channel with a Spring Cloud Stream Sink 34 | like the https://github.com/spring-cloud/stream-applications/tree/main/applications/sink/log-sink[log sink] using the following: 35 | 36 | [source,shell] 37 | ---- 38 | $ java -jar /log-sink-rabbit-3.1.2.jar --server.port=9090 39 | --spring.cloud.stream.bindings.input.destination=job-execution-events 40 | ---- 41 | 42 | == Dependencies: 43 | 44 | The batch-events sample requires an instance of RabbitMQ to be running. 45 | -------------------------------------------------------------------------------- /spring-cloud-task-samples/batch-events/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | logging.level.org.springframework.cloud.task=DEBUG 2 | logging.level.org.springframework.cloud.stream=DEBUG 3 | spring.application.name=batchEvents 4 | -------------------------------------------------------------------------------- /spring-cloud-task-samples/batch-events/src/main/resources/logback-test.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /spring-cloud-task-samples/batch-events/src/test/resources/io/spring/task/listener/job-listener-sink-channel.properties: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2015-2019 the original author or authors. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # https://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | spring.cloud.stream.bindings.input.destination=job-execution-events 17 | spring.cloud.stream.bindings.input.group=testgroup 18 | -------------------------------------------------------------------------------- /spring-cloud-task-samples/batch-job/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spring-cloud/spring-cloud-task/b9dfa48bb3b4970f68008340a28d31dfb79b8ea5/spring-cloud-task-samples/batch-job/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /spring-cloud-task-samples/batch-job/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip 2 | -------------------------------------------------------------------------------- /spring-cloud-task-samples/batch-job/README.adoc: -------------------------------------------------------------------------------- 1 | = Spring Batch Job Task 2 | 3 | This is a Spring Cloud Task application that executes a single Spring Batch Job. 4 | 5 | == Requirements: 6 | 7 | * Java 17 or Above 8 | 9 | == Classes: 10 | 11 | * BatchJobApplication - the Spring Boot Main Application 12 | * JobConfiguration - the configuration for the Spring Batch jobs 13 | 14 | == Build: 15 | 16 | [source,shell] 17 | ---- 18 | mvn clean package 19 | ---- 20 | 21 | == Run: 22 | 23 | [source,shell] 24 | ---- 25 | java -jar target/batch-job-3.0.0.jar 26 | ---- 27 | 28 | == Native Build: 29 | 30 | [source,shell] 31 | ---- 32 | mvn -Pnative native:compile 33 | ---- 34 | 35 | == Native Run: 36 | 37 | [source,shell] 38 | ---- 39 | ./target/batch-job 40 | ---- 41 | 42 | == Run the application with a Postgesql test container 43 | [source,shell] 44 | ---- 45 | ./mvnw spring-boot:test-run 46 | ---- 47 | -------------------------------------------------------------------------------- /spring-cloud-task-samples/batch-job/src/main/java/io/spring/BatchJobApplication.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.spring; 18 | 19 | import org.springframework.boot.SpringApplication; 20 | import org.springframework.boot.autoconfigure.SpringBootApplication; 21 | import org.springframework.cloud.task.configuration.EnableTask; 22 | 23 | @EnableTask 24 | @SpringBootApplication 25 | public class BatchJobApplication { 26 | 27 | public static void main(String[] args) { 28 | SpringApplication.run(BatchJobApplication.class, args); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /spring-cloud-task-samples/batch-job/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=Demo Batch Job Task 2 | logging.level.org.springframework.cloud.task=DEBUG 3 | -------------------------------------------------------------------------------- /spring-cloud-task-samples/batch-job/src/test/java/io/spring/BatchJobTestConfiguration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.spring; 18 | 19 | import org.springframework.boot.test.context.TestConfiguration; 20 | import org.springframework.boot.testcontainers.service.connection.ServiceConnection; 21 | import org.springframework.context.annotation.Bean; 22 | import org.testcontainers.containers.PostgreSQLContainer; 23 | import org.testcontainers.utility.DockerImageName; 24 | 25 | @TestConfiguration(proxyBeanMethods = false) 26 | class BatchJobTestConfiguration { 27 | 28 | @Bean 29 | @ServiceConnection 30 | public PostgreSQLContainer postgresSQLContainer() { 31 | return new PostgreSQLContainer(DockerImageName.parse("postgres:15.1")); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /spring-cloud-task-samples/batch-job/src/test/java/io/spring/TestBatchJobApp.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.spring; 18 | 19 | import org.springframework.boot.SpringApplication; 20 | 21 | public class TestBatchJobApp { 22 | 23 | public static void main(String[] args) { 24 | String[] myArgs = { "--spring.batch.jdbc.initialize-schema=always" }; 25 | SpringApplication.from(BatchJobApplication::main).with(BatchJobTestConfiguration.class).run(myArgs); 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /spring-cloud-task-samples/batch-job/src/test/resources/application.properties: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2016-2019 the original author or authors. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # https://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | 17 | logging.level.root=DEBUG 18 | spring.application.name=Demo Batch Job Task 19 | -------------------------------------------------------------------------------- /spring-cloud-task-samples/jpa-sample/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spring-cloud/spring-cloud-task/b9dfa48bb3b4970f68008340a28d31dfb79b8ea5/spring-cloud-task-samples/jpa-sample/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /spring-cloud-task-samples/jpa-sample/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip 2 | -------------------------------------------------------------------------------- /spring-cloud-task-samples/jpa-sample/README.adoc: -------------------------------------------------------------------------------- 1 | = JPA Sample Task 2 | 3 | This is a Spring Cloud Task Boot Application that uses JPA to persist data to 4 | a data store. 5 | 6 | == Requirements: 7 | 8 | * Java 17 or Above 9 | 10 | == Classes: 11 | 12 | * JpaApplication - the Spring Boot Main Application. 13 | * TaskRunComponent - Component responsible for writing data to the repository. 14 | * TaskRunOutput - Entity to be written to the repository. 15 | 16 | == Build: 17 | 18 | [source,shell] 19 | ---- 20 | mvn clean package 21 | ---- 22 | 23 | == Run: 24 | 25 | [source,shell] 26 | ---- 27 | java -jar target/jpa-sample-3.0.0.jar 28 | ---- 29 | 30 | == Native Build: 31 | 32 | [source,shell] 33 | ---- 34 | mvn -Pnative native:compile 35 | ---- 36 | 37 | == Native Run: 38 | 39 | [source,shell] 40 | ---- 41 | ./target/jpa-sample 42 | ---- 43 | -------------------------------------------------------------------------------- /spring-cloud-task-samples/jpa-sample/src/main/java/io/spring/JpaApplication.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.spring; 18 | 19 | import org.springframework.boot.SpringApplication; 20 | import org.springframework.boot.autoconfigure.SpringBootApplication; 21 | import org.springframework.cloud.task.configuration.EnableTask; 22 | 23 | @EnableTask 24 | @SpringBootApplication 25 | public class JpaApplication { 26 | 27 | public static void main(String[] args) { 28 | SpringApplication.run(JpaApplication.class, args); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /spring-cloud-task-samples/jpa-sample/src/main/java/io/spring/configuration/TaskRunComponent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.spring.configuration; 18 | 19 | import java.text.SimpleDateFormat; 20 | import java.util.Date; 21 | 22 | import org.apache.commons.logging.Log; 23 | import org.apache.commons.logging.LogFactory; 24 | 25 | import org.springframework.beans.factory.annotation.Autowired; 26 | import org.springframework.cloud.task.listener.annotation.BeforeTask; 27 | import org.springframework.cloud.task.repository.TaskExecution; 28 | import org.springframework.stereotype.Component; 29 | 30 | /** 31 | * Records an entry in the TASK_RUN_OUTPUT table on the BeforeTask event. 32 | * 33 | * @author Glenn Renfro 34 | * @author Pas Apicella 35 | */ 36 | @Component 37 | public class TaskRunComponent { 38 | 39 | private static final Log logger = LogFactory.getLog(TaskRunComponent.class); 40 | 41 | @Autowired 42 | private TaskRunRepository taskRunRepository; 43 | 44 | @BeforeTask 45 | public void init(TaskExecution taskExecution) { 46 | String execDate = new SimpleDateFormat().format(new Date()); 47 | this.taskRunRepository.save(new TaskRunOutput("Executed at " + execDate)); 48 | logger.info("Executed at : " + execDate); 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /spring-cloud-task-samples/jpa-sample/src/main/java/io/spring/configuration/TaskRunOutput.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.spring.configuration; 18 | 19 | import jakarta.persistence.Entity; 20 | import jakarta.persistence.GeneratedValue; 21 | import jakarta.persistence.GenerationType; 22 | import jakarta.persistence.Id; 23 | import jakarta.persistence.Table; 24 | 25 | /** 26 | * Entity for the id and output to be written to the data store. 27 | * 28 | * @author Pas Apicella 29 | * @author Glenn Renfro 30 | */ 31 | @Entity 32 | @Table(name = "TASK_RUN_OUTPUT") 33 | public class TaskRunOutput { 34 | 35 | @Id 36 | @GeneratedValue(strategy = GenerationType.AUTO) 37 | private Long id; 38 | 39 | private String output; 40 | 41 | public TaskRunOutput() { 42 | } 43 | 44 | public TaskRunOutput(String output) { 45 | this.output = output; 46 | } 47 | 48 | public Long getId() { 49 | return this.id; 50 | } 51 | 52 | public void setId(Long id) { 53 | this.id = id; 54 | } 55 | 56 | public String getOutput() { 57 | return this.output; 58 | } 59 | 60 | public void setOutput(String output) { 61 | this.output = output; 62 | } 63 | 64 | @Override 65 | public String toString() { 66 | return "TaskRunOutput{" + "id=" + this.id + ", output='" + this.output + '\'' + '}'; 67 | } 68 | 69 | } 70 | -------------------------------------------------------------------------------- /spring-cloud-task-samples/jpa-sample/src/main/java/io/spring/configuration/TaskRunRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.spring.configuration; 18 | 19 | import org.springframework.data.jpa.repository.JpaRepository; 20 | 21 | /** 22 | * @author Pas Apicella 23 | * @author Glenn Renfro 24 | */ 25 | public interface TaskRunRepository extends JpaRepository { 26 | 27 | } 28 | -------------------------------------------------------------------------------- /spring-cloud-task-samples/jpa-sample/src/main/resources/application-cloud.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | jpa: 3 | hibernate: 4 | ddl-auto: update 5 | show-sql: true 6 | -------------------------------------------------------------------------------- /spring-cloud-task-samples/jpa-sample/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | jpa: 3 | hibernate: 4 | ddl-auto: update 5 | show-sql: true 6 | application: 7 | name: Spring Cloud Task JPA Sample Application 8 | logging: 9 | level: 10 | org: 11 | springframework: 12 | cloud: 13 | task: debug 14 | -------------------------------------------------------------------------------- /spring-cloud-task-samples/jpa-sample/src/test/resources/application.properties: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2018-2019 the original author or authors. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # https://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | logging.level.root=DEBUG 17 | spring.application.name=Spring Cloud Task JPA Sample Application 18 | -------------------------------------------------------------------------------- /spring-cloud-task-samples/multiple-datasources/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spring-cloud/spring-cloud-task/b9dfa48bb3b4970f68008340a28d31dfb79b8ea5/spring-cloud-task-samples/multiple-datasources/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /spring-cloud-task-samples/multiple-datasources/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip 2 | -------------------------------------------------------------------------------- /spring-cloud-task-samples/multiple-datasources/README.adoc: -------------------------------------------------------------------------------- 1 | = Multiple DataSources Sample Task 2 | 3 | This is a Spring Boot application that utilizes two DataSources and explicitly configures 4 | which one to be used for the Spring Cloud Task repository. 5 | 6 | == Requirements: 7 | 8 | * Java 17 or Above 9 | 10 | == Classes: 11 | 12 | * `MultipleDataSourcesApplication` - the Spring Boot Main Application. 13 | * `SampleCommandLineRunner` - the `CommandLineRunner` implementation for this task. It outputs the number of `DataSource` beans found in the context (should be 2). 14 | * `EmbeddedDataSourceConfiguration` - Configures two `DataSource` beans using embedded databases. 15 | * `ExternalDataSourceConfiguration` - Configures two `DataSource` beans using external databases. 16 | 17 | * `CustomTaskConfigurer` - Uses a Spring `@Qualifier` to specify the correct `DataSource` to use. 18 | 19 | == Build: 20 | 21 | [source,shell] 22 | ---- 23 | mvn clean package 24 | ---- 25 | 26 | == Execute sample using 2 embedded databases (default): 27 | 28 | [source,shell] 29 | ---- 30 | java -jar target/multiple-datasources-3.0.0.jar 31 | ---- 32 | 33 | == Native Build: 34 | 35 | [source,shell] 36 | ---- 37 | mvn -Pnative native:compile 38 | ---- 39 | 40 | == RUn sample using 2 embedded databases (default) with native app: 41 | 42 | [source,shell] 43 | ---- 44 | ./target/multiple-datasources 45 | ---- 46 | 47 | == Execute sample using 2 external databases: 48 | 49 | Using the `external` profile, users will be able to establish both the default `spring.datasource` data source and a `second.datasource` data source. 50 | For example: 51 | [source,shell,indent=2] 52 | ---- 53 | export spring_datasource_url= 54 | export spring_datasource_username= 55 | export spring_datasource_password= 56 | export spring_datasource_driverClassName=org.mariadb.jdbc.Driver 57 | export second_datasource_url=jdbc: 58 | export second_datasource_username= 59 | export second_datasource_password= 60 | export second_datasource_driverClassName=org.mariadb.jdbc.Driver 61 | java -jar target/multiple-datasources-2.3.0-RELEASE.jar --spring.profiles.active=external 62 | ---- 63 | -------------------------------------------------------------------------------- /spring-cloud-task-samples/multiple-datasources/src/main/java/io/spring/MultipleDataSourcesApplication.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.spring; 18 | 19 | import org.springframework.boot.SpringApplication; 20 | import org.springframework.boot.autoconfigure.SpringBootApplication; 21 | import org.springframework.cloud.task.configuration.EnableTask; 22 | 23 | /** 24 | * @author Michael Minella 25 | */ 26 | @EnableTask 27 | @SpringBootApplication 28 | public class MultipleDataSourcesApplication { 29 | 30 | public static void main(String[] args) { 31 | SpringApplication.run(MultipleDataSourcesApplication.class, args); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /spring-cloud-task-samples/multiple-datasources/src/main/java/io/spring/configuration/CustomTaskConfigurer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.spring.configuration; 18 | 19 | import javax.sql.DataSource; 20 | 21 | import org.springframework.beans.factory.annotation.Autowired; 22 | import org.springframework.beans.factory.annotation.Qualifier; 23 | import org.springframework.cloud.task.configuration.DefaultTaskConfigurer; 24 | import org.springframework.stereotype.Component; 25 | 26 | /** 27 | * @author Michael Minella 28 | */ 29 | @Component 30 | public class CustomTaskConfigurer extends DefaultTaskConfigurer { 31 | 32 | @Autowired 33 | public CustomTaskConfigurer(@Qualifier("secondDataSource") DataSource dataSource) { 34 | super(dataSource); 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /spring-cloud-task-samples/multiple-datasources/src/main/java/io/spring/configuration/EmbeddedDataSourceConfiguration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.spring.configuration; 18 | 19 | import javax.sql.DataSource; 20 | 21 | import org.springframework.context.annotation.Bean; 22 | import org.springframework.context.annotation.Configuration; 23 | import org.springframework.context.annotation.Profile; 24 | import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder; 25 | import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType; 26 | 27 | /** 28 | * Creates two data sources that use embedded databases. 29 | * 30 | * @author Michael Minella 31 | * @author Glenn Renfro 32 | */ 33 | @Configuration(proxyBeanMethods = false) 34 | @Profile("embedded") 35 | public class EmbeddedDataSourceConfiguration { 36 | 37 | @Bean 38 | public DataSource dataSource() { 39 | return new EmbeddedDatabaseBuilder().setType(EmbeddedDatabaseType.H2).build(); 40 | } 41 | 42 | @Bean 43 | public DataSource secondDataSource() { 44 | return new EmbeddedDatabaseBuilder().setType(EmbeddedDatabaseType.H2).build(); 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /spring-cloud-task-samples/multiple-datasources/src/main/java/io/spring/task/SampleCommandLineRunner.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.spring.task; 18 | 19 | import java.util.List; 20 | 21 | import javax.sql.DataSource; 22 | 23 | import org.springframework.beans.factory.annotation.Autowired; 24 | import org.springframework.boot.CommandLineRunner; 25 | import org.springframework.stereotype.Component; 26 | 27 | /** 28 | * @author Michael Minella 29 | */ 30 | @Component 31 | public class SampleCommandLineRunner implements CommandLineRunner { 32 | 33 | private List dataSources; 34 | 35 | @Autowired 36 | public SampleCommandLineRunner(List dataSources) { 37 | this.dataSources = dataSources; 38 | } 39 | 40 | @Override 41 | public void run(String... args) throws Exception { 42 | System.out.println("There are " + this.dataSources.size() + " DataSources within this application"); 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /spring-cloud-task-samples/multiple-datasources/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=Demo Multiple DataSources Task 2 | logging.level.org.springframework.cloud.task=DEBUG 3 | 4 | spring.profiles.active=embedded 5 | -------------------------------------------------------------------------------- /spring-cloud-task-samples/multiple-datasources/src/test/java/io/spring/MultiDataSourcesApplicationTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.spring; 18 | 19 | import org.junit.jupiter.api.Test; 20 | import org.junit.jupiter.api.extension.ExtendWith; 21 | 22 | import org.springframework.boot.SpringApplication; 23 | import org.springframework.boot.test.system.CapturedOutput; 24 | import org.springframework.boot.test.system.OutputCaptureExtension; 25 | 26 | import static org.assertj.core.api.Assertions.assertThat; 27 | 28 | /** 29 | * @author Michael Minella 30 | */ 31 | @ExtendWith(OutputCaptureExtension.class) 32 | public class MultiDataSourcesApplicationTests { 33 | 34 | @Test 35 | public void testTimeStampApp(CapturedOutput capturedOutput) throws Exception { 36 | 37 | SpringApplication.run(MultipleDataSourcesApplication.class, "--spring.profiles.active=embedded"); 38 | 39 | String output = capturedOutput.toString(); 40 | 41 | assertThat(output.contains("There are 2 DataSources within this application")) 42 | .as("Unable to find CommandLineRunner output: " + output) 43 | .isTrue(); 44 | assertThat(output.contains("Creating: TaskExecution{")).as("Unable to find start task message: " + output) 45 | .isTrue(); 46 | assertThat(output.contains("Updating: TaskExecution")).as("Unable to find update task message: " + output) 47 | .isTrue(); 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /spring-cloud-task-samples/multiple-datasources/src/test/resources/application.properties: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2016-2019 the original author or authors. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # https://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | spring.application.name=Demo Multiple DataSources Task 17 | logging.level.org.springframework.cloud.task=DEBUG 18 | -------------------------------------------------------------------------------- /spring-cloud-task-samples/partitioned-batch-job/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spring-cloud/spring-cloud-task/b9dfa48bb3b4970f68008340a28d31dfb79b8ea5/spring-cloud-task-samples/partitioned-batch-job/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /spring-cloud-task-samples/partitioned-batch-job/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip 2 | -------------------------------------------------------------------------------- /spring-cloud-task-samples/partitioned-batch-job/src/main/java/io/spring/PartitionedBatchJobApplication.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.spring; 18 | 19 | import org.springframework.boot.SpringApplication; 20 | import org.springframework.boot.autoconfigure.SpringBootApplication; 21 | import org.springframework.cloud.task.configuration.EnableTask; 22 | 23 | @EnableTask 24 | @SpringBootApplication 25 | public class PartitionedBatchJobApplication { 26 | 27 | public static void main(String[] args) { 28 | SpringApplication.run(PartitionedBatchJobApplication.class, args); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /spring-cloud-task-samples/partitioned-batch-job/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=PartitionedBatchJobTask 2 | logging.level.org.springframework.cloud.task=DEBUG 3 | maven.remoteRepositories.springRepo.url=https://repo.spring.io/snapshot 4 | 5 | -------------------------------------------------------------------------------- /spring-cloud-task-samples/single-step-batch-job/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spring-cloud/spring-cloud-task/b9dfa48bb3b4970f68008340a28d31dfb79b8ea5/spring-cloud-task-samples/single-step-batch-job/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /spring-cloud-task-samples/single-step-batch-job/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip 2 | -------------------------------------------------------------------------------- /spring-cloud-task-samples/single-step-batch-job/src/main/java/io/spring/SingleStepBatchJobApplication.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2020 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.spring; 18 | 19 | import org.springframework.boot.SpringApplication; 20 | import org.springframework.boot.autoconfigure.SpringBootApplication; 21 | import org.springframework.cloud.task.configuration.EnableTask; 22 | 23 | @EnableTask 24 | @SpringBootApplication 25 | public class SingleStepBatchJobApplication { 26 | 27 | public static void main(String[] args) { 28 | SpringApplication.run(SingleStepBatchJobApplication.class, args); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /spring-cloud-task-samples/single-step-batch-job/src/main/resources/application-amqpreader.properties: -------------------------------------------------------------------------------- 1 | spring.batch.job.amqpitemreader.name=testreader 2 | spring.cloud.task.closecontextEnabled=true 3 | spring.batch.job.amqpitemreader.enabled=true 4 | spring.rabbitmq.template.defaultReceiveQueue=samplequeue 5 | spring.rabbitmq.host=localhost 6 | spring.rabbitmq.port=5672 7 | -------------------------------------------------------------------------------- /spring-cloud-task-samples/single-step-batch-job/src/main/resources/application-amqpwriter.properties: -------------------------------------------------------------------------------- 1 | spring.batch.job.amqpitemwriter.enabled=true 2 | spring.cloud.task.closecontextEnabled=true 3 | spring.rabbitmq.template.exchange=sampleexchange 4 | -------------------------------------------------------------------------------- /spring-cloud-task-samples/single-step-batch-job/src/main/resources/application-ffreader.properties: -------------------------------------------------------------------------------- 1 | spring.batch.job.flatfileitemreader.savestate=true 2 | spring.batch.job.flatfileitemreader.name=fixedWidthConfiguration 3 | spring.batch.job.flatfileitemreader.comments=#,$ 4 | spring.batch.job.flatfileitemreader.resource=/test.txt 5 | spring.batch.job.flatfileitemreader.strict=true 6 | spring.batch.job.flatfileitemreader.fixedLength=true 7 | spring.batch.job.flatfileitemreader.ranges=1-3 8 | spring.batch.job.flatfileitemreader.names=ITEM_NAME 9 | spring.batch.job.flatfileitemreader.parsingStrict=false 10 | -------------------------------------------------------------------------------- /spring-cloud-task-samples/single-step-batch-job/src/main/resources/application-ffwriter.properties: -------------------------------------------------------------------------------- 1 | spring.batch.job.flatfileitemwriter.name=fooWriter 2 | spring.batch.job.flatfileitemwriter.resource=file:result.txt 3 | spring.batch.job.flatfileitemwriter.encoding=UTF-16 4 | spring.batch.job.flatfileitemwriter.saveState=false 5 | spring.batch.job.flatfileitemwriter.shouldDeleteIfEmpty=true 6 | spring.batch.job.flatfileitemwriter.delimited=true 7 | spring.batch.job.flatfileitemwriter.names=ITEM_NAME 8 | spring.batch.job.flatfileitemwriter.append=true 9 | spring.batch.job.flatfileitemwriter.forceSync=true 10 | spring.batch.job.flatfileitemwriter.shouldDeleteIfExists=false 11 | spring.batch.job.flatfileitemwriter.transactional=false 12 | -------------------------------------------------------------------------------- /spring-cloud-task-samples/single-step-batch-job/src/main/resources/application-jdbcreader.properties: -------------------------------------------------------------------------------- 1 | spring.batch.job.jdbccursoritemreader.name=fooReader 2 | spring.batch.job.jdbccursoritemreader.sql=select item_name from item_sample order by item_name 3 | -------------------------------------------------------------------------------- /spring-cloud-task-samples/single-step-batch-job/src/main/resources/application-jdbcwriter.properties: -------------------------------------------------------------------------------- 1 | spring.batch.job.jdbcbatchitemwriter.name=jdbcWriter 2 | spring.batch.job.jdbcbatchitemwriter.sql=INSERT INTO item (item_name) VALUES (:ITEM_NAME) 3 | -------------------------------------------------------------------------------- /spring-cloud-task-samples/single-step-batch-job/src/main/resources/application-kafkareader.properties: -------------------------------------------------------------------------------- 1 | spring.kafka.consumer.bootstrapServers=localhost:9092 2 | spring.batch.job.kafkaitemreader.name=testreader 3 | spring.kafka.consumer.groupId=1 4 | spring.kafka.consumer.bootstrapServers=localhost:9092 5 | spring.kafka.consumer.valueDeserializer=org.springframework.kafka.support.serializer.JsonDeserializer 6 | spring.kafka.consumer.keyDeserializer=org.springframework.kafka.support.serializer.JsonDeserializer 7 | spring.batch.job.kafkaitemreader.topic=sampletopic 8 | spring.batch.job.kafkaitemreader.pollTimeOutInSeconds=2 9 | -------------------------------------------------------------------------------- /spring-cloud-task-samples/single-step-batch-job/src/main/resources/application-kafkawriter.properties: -------------------------------------------------------------------------------- 1 | spring.kafka.producer.bootstrapServers=localhost:9092 2 | spring.kafka.producer.keySerializer=org.springframework.kafka.support.serializer.JsonSerializer 3 | spring.kafka.producer.valueSerializer=org.springframework.kafka.support.serializer.JsonSerializer 4 | spring.batch.job.kafkaitemwriter.topic=sampletopic 5 | -------------------------------------------------------------------------------- /spring-cloud-task-samples/single-step-batch-job/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=Single Step Batch Job 2 | spring.batch.job.jobName=job 3 | spring.batch.job.stepName=step1 4 | spring.batch.job.chunkSize=5 5 | spring.batch.jdbc.initialize-schema=always 6 | logging.level.org.springframework.cloud.task=debug 7 | -------------------------------------------------------------------------------- /spring-cloud-task-samples/single-step-batch-job/src/main/resources/test.txt: -------------------------------------------------------------------------------- 1 | foo 2 | bar 3 | baz 4 | qux 5 | boo 6 | Job 7 | -------------------------------------------------------------------------------- /spring-cloud-task-samples/single-step-batch-job/src/test/resources/schema-h2.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE IF NOT EXISTS item 2 | ( 3 | item_name varchar(55) 4 | ); 5 | 6 | CREATE TABLE IF NOT EXISTS item_sample 7 | ( 8 | item_name varchar(55) 9 | ); 10 | 11 | INSERT INTO item_sample (item_name) VALUES ('foo'); 12 | INSERT INTO item_sample (item_name) VALUES ('bar'); 13 | INSERT INTO item_sample (item_name) VALUES ('baz'); 14 | INSERT INTO item_sample (item_name) VALUES ('boo'); 15 | INSERT INTO item_sample (item_name) VALUES ('qux'); 16 | INSERT INTO item_sample (item_name) VALUES ('Job'); 17 | -------------------------------------------------------------------------------- /spring-cloud-task-samples/single-step-batch-job/src/test/resources/test.txt: -------------------------------------------------------------------------------- 1 | Job 2 | bar 3 | baz 4 | boo 5 | foo 6 | qux 7 | -------------------------------------------------------------------------------- /spring-cloud-task-samples/single-step-batch-job/src/test/resources/testresult.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spring-cloud/spring-cloud-task/b9dfa48bb3b4970f68008340a28d31dfb79b8ea5/spring-cloud-task-samples/single-step-batch-job/src/test/resources/testresult.txt -------------------------------------------------------------------------------- /spring-cloud-task-samples/task-events/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spring-cloud/spring-cloud-task/b9dfa48bb3b4970f68008340a28d31dfb79b8ea5/spring-cloud-task-samples/task-events/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /spring-cloud-task-samples/task-events/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip 2 | -------------------------------------------------------------------------------- /spring-cloud-task-samples/task-events/README.adoc: -------------------------------------------------------------------------------- 1 | = Task Events 2 | 3 | This is a task application that emits events on a channel named `task-events` 4 | 5 | == Requirements: 6 | 7 | * Java 17 or Above 8 | 9 | == Build: 10 | 11 | [source,shell] 12 | ---- 13 | ./mvnw clean install 14 | ---- 15 | 16 | == Execution: 17 | 18 | [source,shell] 19 | ---- 20 | java -jar target/task-events-3.0.0.RELEASE.jar 21 | ---- 22 | 23 | You can listen for the events on the task-events channel with a Spring Cloud Stream Sink 24 | like the https://github.com/spring-cloud/stream-applications/tree/main/applications/sink/log-sink[log sink] using the following: 25 | 26 | [source,shell] 27 | ---- 28 | java -jar /log-sink-rabbit-3.1.2.jar --server.port=9090 --spring.cloud.stream.bindings.input.destination=task-events 29 | ---- 30 | 31 | == Dependencies: 32 | 33 | The task-events sample requires an instance of RabbitMQ to be running. 34 | -------------------------------------------------------------------------------- /spring-cloud-task-samples/task-events/src/main/java/io/spring/TaskEventsApplication.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.spring; 18 | 19 | import org.springframework.boot.CommandLineRunner; 20 | import org.springframework.boot.SpringApplication; 21 | import org.springframework.boot.autoconfigure.SpringBootApplication; 22 | import org.springframework.cloud.task.configuration.EnableTask; 23 | import org.springframework.context.annotation.Bean; 24 | import org.springframework.context.annotation.Configuration; 25 | 26 | @EnableTask 27 | @SpringBootApplication 28 | public class TaskEventsApplication { 29 | 30 | public static void main(String[] args) { 31 | SpringApplication.run(TaskEventsApplication.class, args); 32 | } 33 | 34 | @Configuration(proxyBeanMethods = false) 35 | public static class TaskConfiguration { 36 | 37 | @Bean 38 | public CommandLineRunner commandLineRunner() { 39 | return new CommandLineRunner() { 40 | @Override 41 | public void run(String... args) throws Exception { 42 | System.out.println("The CommandLineRunner was executed"); 43 | } 44 | }; 45 | } 46 | 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /spring-cloud-task-samples/task-events/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=Event Emitting Task 2 | logging.level.org.springframework.cloud.stream=DEBUG 3 | logging.level.org.springframework.cloud.task=DEBUG 4 | 5 | -------------------------------------------------------------------------------- /spring-cloud-task-samples/task-observations/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /spring-cloud-task-samples/task-observations/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spring-cloud/spring-cloud-task/b9dfa48bb3b4970f68008340a28d31dfb79b8ea5/spring-cloud-task-samples/task-observations/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /spring-cloud-task-samples/task-observations/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.4/apache-maven-3.8.4-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar 3 | -------------------------------------------------------------------------------- /spring-cloud-task-samples/task-observations/README.adoc: -------------------------------------------------------------------------------- 1 | = Timestamp Task 2 | 3 | This is a Spring Cloud Task application that utilizes Micrometer and displays 4 | metrics at the end of the application using the SimpleMeterRegistry. 5 | 6 | == Requirements: 7 | 8 | * Java 17 or Above 9 | 10 | == Classes: 11 | 12 | * TaskObservationsApplication - the Spring Boot Main Application 13 | 14 | == Build: 15 | 16 | [source,shell] 17 | ---- 18 | mvn clean package 19 | ---- 20 | 21 | == Run: 22 | 23 | [source,shell] 24 | ---- 25 | java -jar target/task-observations-3.0.0.jar 26 | ---- 27 | 28 | == Native Build: 29 | 30 | [source,shell] 31 | ---- 32 | mvn -Pnative clean package 33 | ---- 34 | 35 | == Native Run: 36 | 37 | [source,shell] 38 | ---- 39 | ./target/task-observations 40 | ---- 41 | -------------------------------------------------------------------------------- /spring-cloud-task-samples/task-observations/src/main/java/io/spring/taskobservations/ObservationConfiguration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022-2022 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.spring.taskobservations; 18 | 19 | import io.micrometer.core.instrument.simple.SimpleMeterRegistry; 20 | 21 | import org.springframework.context.annotation.Bean; 22 | import org.springframework.context.annotation.Configuration; 23 | 24 | @Configuration 25 | public class ObservationConfiguration { 26 | 27 | @Bean 28 | public SimpleMeterRegistry meterRegistry() { 29 | return new SimpleMeterRegistry(); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /spring-cloud-task-samples/task-observations/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | logging.level.org.springframework.cloud.task=debug 2 | management.metrics.tags.service=task-observations-application 3 | management.metrics.tags.application=task-observations-application-58 4 | spring.cloud.task.name=taskmetrics 5 | spring.cloud.task.observation.enabled=true 6 | 7 | -------------------------------------------------------------------------------- /spring-cloud-task-samples/task-observations/src/test/java/io/spring/taskobservations/TaskObservationsApplicationTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022-2022 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.spring.taskobservations; 18 | 19 | import org.junit.jupiter.api.Test; 20 | import org.junit.jupiter.api.extension.ExtendWith; 21 | 22 | import org.springframework.boot.test.context.SpringBootTest; 23 | import org.springframework.boot.test.system.CapturedOutput; 24 | import org.springframework.boot.test.system.OutputCaptureExtension; 25 | 26 | import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat; 27 | 28 | @SpringBootTest 29 | @ExtendWith(OutputCaptureExtension.class) 30 | class TaskObservationsApplicationTests { 31 | 32 | @Test 33 | void contextLoads(CapturedOutput output) { 34 | String result = output.getAll(); 35 | assertThat(result).contains("spring.cloud.task(TIMER)[application='task-observations-application-58', " 36 | + "error='none', service='task-observations-application', " 37 | + "spring.cloud.task.execution.id='1', spring.cloud.task.exit.code='0', " 38 | + "spring.cloud.task.external.execution.id='unknown', spring.cloud.task.name='taskmetrics', " 39 | + "spring.cloud.task.parent.execution.id='unknown', spring.cloud.task.status='success']; " 40 | + "count=1.0, total_time="); 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /spring-cloud-task-samples/taskprocessor/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spring-cloud/spring-cloud-task/b9dfa48bb3b4970f68008340a28d31dfb79b8ea5/spring-cloud-task-samples/taskprocessor/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /spring-cloud-task-samples/taskprocessor/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip 2 | -------------------------------------------------------------------------------- /spring-cloud-task-samples/taskprocessor/README.adoc: -------------------------------------------------------------------------------- 1 | = TaskProcessor 2 | 3 | Is a stream processor that will accept messages with a string payload and create a 4 | `TaskLaunchRequest` that it will send to the next app in the stream. The payload of the 5 | message that is sent will be added to the properties of the `TaskLaunchRequest` under 6 | the `payload` key. 7 | 8 | By default the processor will add the timestamp-task sample coordinates if no task is 9 | specified. 10 | 11 | NOTE: if using defaults make sure to install the timestamp-task into your local maven repo 12 | by executing the following build in the timestamp-task module: 13 | 14 | [source,shell] 15 | ---- 16 | ./mvnw clean install 17 | ---- 18 | 19 | == The arguments offered by the TaskProcessor are as follows: 20 | * *group* establishes the group for the task maven coordinates. Default is `io.spring`. 21 | * *artifact* establishes the artifact for the task maven coordinates. Default is `timestamp-task`. 22 | * *classifiers* establishes the classifier for the task maven coordinates. Default is null. 23 | * *extension* establishes the extension for the task maven coordinates. Default is jar. 24 | * *data-source-url* sets the spring_datasource_url for the task. Default is null. 25 | * *data-source-driver-class-name* establishes the spring_datasource_driverClassName for the task. Default is null. 26 | * *data-source-user-name* establishes the spring_datasource_username for the task. Default is null. 27 | * *data-source-password* establishes the spring_datasource_password for the task. Default is null. 28 | 29 | == Requirements: 30 | 31 | * Java 17 or Above 32 | 33 | == Build: 34 | 35 | [source,shell] 36 | ---- 37 | ./mvnw clean install 38 | ---- 39 | 40 | == Dependencies: 41 | 42 | The task processor requires an instance of RabbitMQ to be running. 43 | -------------------------------------------------------------------------------- /spring-cloud-task-samples/taskprocessor/src/main/java/io/spring/TaskProcessorApplication.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.spring; 18 | 19 | import org.springframework.boot.SpringApplication; 20 | import org.springframework.boot.autoconfigure.SpringBootApplication; 21 | 22 | /** 23 | * @author Glenn Renfro 24 | */ 25 | @SpringBootApplication 26 | public class TaskProcessorApplication { 27 | 28 | public static void main(String[] args) { 29 | SpringApplication.run(TaskProcessorApplication.class, args); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /spring-cloud-task-samples/taskprocessor/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | maven.remoteRepositories.springRepo.url=https://repo.spring.io/snapshot 2 | spring.cloud.stream.function.bindings.processRequest-in-0=input 3 | spring.cloud.stream.function.bindings.processRequest-out-0=output 4 | -------------------------------------------------------------------------------- /spring-cloud-task-samples/tasksink/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spring-cloud/spring-cloud-task/b9dfa48bb3b4970f68008340a28d31dfb79b8ea5/spring-cloud-task-samples/tasksink/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /spring-cloud-task-samples/tasksink/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip 2 | -------------------------------------------------------------------------------- /spring-cloud-task-samples/tasksink/README.adoc: -------------------------------------------------------------------------------- 1 | = TaskSink 2 | 3 | Is a stream sink that will accept messages with the payload of `TaskLaunchRequest` and 4 | launch the task that was specified in the request. 5 | 6 | == Requirements: 7 | 8 | * Java 17 or Above 9 | 10 | == Build: 11 | 12 | [source,shell] 13 | ---- 14 | ./mvnw clean install 15 | ---- 16 | 17 | == Dependencies: 18 | 19 | The task sink requires an instance of RabbitMQ to be running. 20 | -------------------------------------------------------------------------------- /spring-cloud-task-samples/tasksink/src/main/java/io/spring/TaskSinkApplication.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.spring; 18 | 19 | import org.springframework.boot.SpringApplication; 20 | import org.springframework.boot.autoconfigure.SpringBootApplication; 21 | import org.springframework.cloud.task.launcher.annotation.EnableTaskLauncher; 22 | 23 | /** 24 | * A task sink sample application for launching tasks. 25 | * 26 | * @author Glenn Renfro 27 | */ 28 | @SpringBootApplication 29 | @EnableTaskLauncher 30 | public class TaskSinkApplication { 31 | 32 | public static void main(String[] args) { 33 | SpringApplication.run(TaskSinkApplication.class, args); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /spring-cloud-task-samples/tasksink/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | maven.remoteRepositories.springRepo.url=https://repo.spring.io/snapshot 2 | spring.cloud.stream.function.bindings.taskLauncherSink-in-0=input 3 | spring.cloud.stream.bindings.input.destination=taskLauncherSinkExchange 4 | 5 | -------------------------------------------------------------------------------- /spring-cloud-task-samples/tasksink/src/test/java/io/spring/configuration/TaskSinkConfiguration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.spring.configuration; 18 | 19 | import org.springframework.cloud.deployer.spi.task.TaskLauncher; 20 | import org.springframework.context.annotation.Bean; 21 | import org.springframework.context.annotation.Configuration; 22 | 23 | import static org.mockito.Mockito.mock; 24 | 25 | /** 26 | * @author Glenn Renfro 27 | */ 28 | @Configuration(proxyBeanMethods = false) 29 | public class TaskSinkConfiguration { 30 | 31 | @Bean 32 | public TaskLauncher taskLauncher() { 33 | return mock(TaskLauncher.class); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /spring-cloud-task-samples/tasksink/src/test/resources/application.properties: -------------------------------------------------------------------------------- 1 | maven.remoteRepositories.springRepo.url=https://repo.spring.io/snapshot 2 | -------------------------------------------------------------------------------- /spring-cloud-task-samples/timestamp/README.adoc: -------------------------------------------------------------------------------- 1 | = Timestamp Task 2 | 3 | This is a Spring Cloud Task application that logs a timestamp. 4 | 5 | == Requirements: 6 | 7 | * Java 17 or Above 8 | 9 | == Classes: 10 | 11 | * TaskApplication - the Spring Boot Main Application 12 | * TimestampTask - the module that writes the log entry as Spring Cloud Task 13 | 14 | == Build: 15 | 16 | [source,shell] 17 | ---- 18 | mvn clean package 19 | ---- 20 | 21 | == Run: 22 | 23 | [source,shell] 24 | ---- 25 | java -jar target/timestamp-task-3.0.0.jar 26 | ---- 27 | 28 | == Native Build: 29 | 30 | [source,shell] 31 | ---- 32 | mvn -Pnative native:compile 33 | ---- 34 | 35 | == Native Run: 36 | 37 | [source,shell] 38 | ---- 39 | ./target/timestamp-task 40 | ---- 41 | -------------------------------------------------------------------------------- /spring-cloud-task-samples/timestamp/src/main/java/org/springframework/cloud/task/timestamp/TimestampTaskProperties.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.cloud.task.timestamp; 18 | 19 | import org.springframework.boot.context.properties.ConfigurationProperties; 20 | import org.springframework.util.Assert; 21 | 22 | /** 23 | * @author Glenn Renfro 24 | */ 25 | @ConfigurationProperties 26 | public class TimestampTaskProperties { 27 | 28 | /** 29 | * The timestamp format, "yyyy-MM-dd HH:mm:ss.SSS" by default. 30 | */ 31 | private String format = "yyyy-MM-dd HH:mm:ss.SSS"; 32 | 33 | public String getFormat() { 34 | Assert.hasText(this.format, "format must not be empty nor null"); 35 | return this.format; 36 | } 37 | 38 | public void setFormat(String format) { 39 | this.format = format; 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /spring-cloud-task-samples/timestamp/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=Demo Timestamp Task 2 | logging.level.org.springframework.cloud.task=DEBUG 3 | #spring.aop.proxy-target-class=false 4 | 5 | -------------------------------------------------------------------------------- /spring-cloud-task-samples/timestamp/src/test/resources/application.properties: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2016-2019 the original author or authors. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # https://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | 17 | logging.level.org.springframework.cloud.task=DEBUG 18 | spring.application.name=Demo Timestamp Task 19 | -------------------------------------------------------------------------------- /spring-cloud-task-stream/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spring-cloud/spring-cloud-task/b9dfa48bb3b4970f68008340a28d31dfb79b8ea5/spring-cloud-task-stream/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /spring-cloud-task-stream/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip 2 | -------------------------------------------------------------------------------- /spring-cloud-task-stream/src/main/java/org/springframework/cloud/task/batch/listener/support/BatchJobHeaders.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.cloud.task.batch.listener.support; 18 | 19 | /** 20 | * Headers definitions used by the batch job plugin. 21 | * 22 | * @author Gunnar Hillert 23 | * @since 1.0 24 | */ 25 | public final class BatchJobHeaders { 26 | 27 | /** 28 | * Name of the batch listener event type. 29 | */ 30 | public static final String BATCH_LISTENER_EVENT_TYPE = "batch_listener_event_type"; 31 | 32 | /** 33 | * Key of the batch exception message. 34 | */ 35 | public static final String BATCH_EXCEPTION = "batch_exception"; 36 | 37 | private BatchJobHeaders() { 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /spring-cloud-task-stream/src/main/java/org/springframework/cloud/task/batch/listener/support/ExitStatus.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.cloud.task.batch.listener.support; 18 | 19 | import org.springframework.util.Assert; 20 | 21 | /** 22 | * ExitStatus DTO created so that {@link org.springframework.batch.core.ExitStatus} can be 23 | * serialized into Json without. having to add mixins to an ObjectMapper 24 | * 25 | * @author Glenn Renfro 26 | */ 27 | public class ExitStatus { 28 | 29 | private String exitCode; 30 | 31 | private String exitDescription; 32 | 33 | public ExitStatus() { 34 | } 35 | 36 | public ExitStatus(org.springframework.batch.core.ExitStatus exitStatus) { 37 | Assert.notNull(exitStatus, "exitStatus must not be null."); 38 | 39 | this.exitCode = exitStatus.getExitCode(); 40 | this.exitDescription = exitStatus.getExitDescription(); 41 | } 42 | 43 | public String getExitCode() { 44 | return this.exitCode; 45 | } 46 | 47 | public void setExitCode(String exitCode) { 48 | this.exitCode = exitCode; 49 | } 50 | 51 | public String getExitDescription() { 52 | return this.exitDescription; 53 | } 54 | 55 | public void setExitDescription(String exitDescription) { 56 | this.exitDescription = exitDescription; 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /spring-cloud-task-stream/src/main/java/org/springframework/cloud/task/batch/listener/support/JobInstanceEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.cloud.task.batch.listener.support; 18 | 19 | import org.springframework.batch.core.Entity; 20 | import org.springframework.util.Assert; 21 | 22 | /** 23 | * This is a JobInstance DTO created so that a 24 | * {@link org.springframework.batch.core.JobInstance} can be serialized into Json without 25 | * having to add mixins to an ObjectMapper. 26 | * 27 | * @author Glenn Renfro 28 | */ 29 | 30 | public class JobInstanceEvent extends Entity { 31 | 32 | private String jobName; 33 | 34 | public JobInstanceEvent() { 35 | super(-1L); 36 | } 37 | 38 | public JobInstanceEvent(Long id, String jobName) { 39 | super(id); 40 | Assert.hasLength(jobName, "jobName must have length greater than zero."); 41 | this.jobName = jobName; 42 | } 43 | 44 | /** 45 | * @return the job name. (Equivalent to getJob().getName()) 46 | */ 47 | public String getJobName() { 48 | return this.jobName; 49 | } 50 | 51 | public String toString() { 52 | return super.toString() + ", Job=[" + this.jobName + "]"; 53 | } 54 | 55 | public long getInstanceId() { 56 | return super.getId(); 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /spring-cloud-task-stream/src/main/resources/META-INF/additional-spring-configuration-metadata.json: -------------------------------------------------------------------------------- 1 | { 2 | "properties": [ 3 | { 4 | "defaultValue": true, 5 | "name": "spring.cloud.task.events.enabled", 6 | "description": "This property is used to determine if a task app should emit task events.", 7 | "type": "java.lang.Boolean" 8 | } 9 | ] 10 | } 11 | -------------------------------------------------------------------------------- /spring-cloud-task-stream/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports: -------------------------------------------------------------------------------- 1 | org.springframework.cloud.task.listener.TaskEventAutoConfiguration 2 | org.springframework.cloud.task.batch.listener.BatchEventAutoConfiguration 3 | org.springframework.cloud.deployer.autoconfigure.ResourceLoadingAutoConfiguration 4 | 5 | -------------------------------------------------------------------------------- /spring-cloud-task-stream/src/main/resources/org/springframework/cloud/task/application.properties: -------------------------------------------------------------------------------- 1 | spring.cloud.stream.bindings.task-events.contentType=application/json 2 | spring.cloud.stream.bindings.item-write-events.contentType=application/json 3 | spring.cloud.stream.bindings.item-read-events.contentType=application/json 4 | spring.cloud.stream.bindings.item-process-events.contentType=application/json 5 | spring.cloud.stream.bindings.skip-events.contentType=application/json 6 | spring.cloud.stream.bindings.step-execution-events.contentType=application/json 7 | spring.cloud.stream.bindings.job-execution-events.contentType=application/json 8 | 9 | 10 | -------------------------------------------------------------------------------- /spring-cloud-task-stream/src/test/java/org/springframework/cloud/task/batch/listener/JobInstanceEventTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.cloud.task.batch.listener; 18 | 19 | import org.junit.jupiter.api.Test; 20 | 21 | import org.springframework.cloud.task.batch.listener.support.JobInstanceEvent; 22 | 23 | import static org.assertj.core.api.Assertions.assertThat; 24 | 25 | /** 26 | * @author Glenn Renfro 27 | */ 28 | public class JobInstanceEventTests { 29 | 30 | private static final long INSTANCE_ID = 1; 31 | 32 | private static final String JOB_NAME = "FOOBAR"; 33 | 34 | @Test 35 | public void testConstructor() { 36 | JobInstanceEvent jobInstanceEvent = new JobInstanceEvent(INSTANCE_ID, JOB_NAME); 37 | assertThat(jobInstanceEvent.getInstanceId()).isEqualTo(INSTANCE_ID); 38 | assertThat(jobInstanceEvent.getJobName()).isEqualTo(JOB_NAME); 39 | } 40 | 41 | @Test 42 | public void testEmptyConstructor() { 43 | JobInstanceEvent jobInstanceEvent = new JobInstanceEvent(); 44 | assertThat(jobInstanceEvent.getJobName()).isNull(); 45 | } 46 | 47 | @Test 48 | public void testEmptyConstructorEmptyId() { 49 | JobInstanceEvent jobInstanceEvent = new JobInstanceEvent(); 50 | jobInstanceEvent.getInstanceId(); 51 | } 52 | 53 | @Test 54 | public void testToString() { 55 | JobInstanceEvent jobInstanceEvent = new JobInstanceEvent(INSTANCE_ID, JOB_NAME); 56 | assertThat(jobInstanceEvent.toString()).isEqualTo("JobInstanceEvent: id=1, version=null, Job=[FOOBAR]"); 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /spring-cloud-task-stream/src/test/java/org/springframework/cloud/task/launcher/app/TaskLauncherSinkApplication.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.cloud.task.launcher.app; 18 | 19 | import org.springframework.boot.SpringApplication; 20 | import org.springframework.boot.autoconfigure.SpringBootApplication; 21 | import org.springframework.cloud.task.launcher.annotation.EnableTaskLauncher; 22 | 23 | /** 24 | * @author Glenn Renfro 25 | */ 26 | // @checkstyle:off 27 | @SpringBootApplication 28 | @EnableTaskLauncher 29 | public class TaskLauncherSinkApplication { 30 | 31 | public static void main(String[] args) { 32 | SpringApplication.run(TaskLauncherSinkApplication.class, args); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /spring-cloud-task-stream/src/test/java/org/springframework/cloud/task/listener/TaskEventTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.cloud.task.listener; 18 | 19 | import org.junit.jupiter.api.Test; 20 | 21 | import org.springframework.boot.WebApplicationType; 22 | import org.springframework.boot.autoconfigure.SpringBootApplication; 23 | import org.springframework.boot.builder.SpringApplicationBuilder; 24 | import org.springframework.cloud.stream.binder.test.TestChannelBinderConfiguration; 25 | import org.springframework.cloud.task.configuration.EnableTask; 26 | import org.springframework.context.ConfigurableApplicationContext; 27 | 28 | import static org.assertj.core.api.Assertions.assertThat; 29 | 30 | /** 31 | * @author Michael Minella 32 | * @author Ilayaperumal Gopinathan 33 | * @author Glenn Renfro 34 | */ 35 | public class TaskEventTests { 36 | 37 | @Test 38 | public void testDefaultConfiguration() { 39 | ConfigurableApplicationContext applicationContext = new SpringApplicationBuilder() 40 | .sources(TestChannelBinderConfiguration.getCompleteConfiguration(TaskEventsApplication.class)) 41 | .web(WebApplicationType.NONE) 42 | .build() 43 | .run(); 44 | assertThat(applicationContext.getBean("taskEventEmitter")).isNotNull(); 45 | } 46 | 47 | @EnableTask 48 | @SpringBootApplication 49 | public static class TaskEventsApplication { 50 | 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /spring-cloud-task-stream/src/test/resources/application.properties: -------------------------------------------------------------------------------- 1 | maven.remoteRepositories.springRepo.url=https://repo.spring.io/snapshot 2 | logging.level.org.springframework.cloud.task.batch.listener=DEBUG 3 | spring.cloud.stream.function.definition=taskLauncherSink 4 | spring.cloud.stream.function.bindings.taskLauncherSink-in-0=input 5 | spring.cloud.stream.bindings.input.group=taskLauncherSink 6 | spring.cloud.stream.bindings.input.destination=taskLauncherSinkExchange 7 | -------------------------------------------------------------------------------- /src/checkstyle/checkstyle-suppressions.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | --------------------------------------------------------------------------------