We are pleased to announce that Spring Cloud Task 2.0.0.M3 is now available on Github and the Pivotal download repository. Many thanks to all of those who contributed to this release.
This release includes upgrades to existing dependencies as well as some exciting new features for users of Spring Cloud Task. From a dependencies perspective, Spring Cloud Task 2.0.0.M3 has been upgraded to use the Spring Boot 2.0.0.RC1 stack as well as Spring Cloud’s Finchley M6 dependencies.
Beyond just a dependency upgrade, there are a number of new features within Spring Cloud Task 2.0.0.M3. Let’s take a look.
Since Spring Cloud Task isn’t responsible for orchestration, it can be hard to prevent multiple instances of the same task being executed at the same time. However, this can be an important use case for things such as database migrations. This release adds a listener that can be used to prevent multiple instances of a task from being executed at the same time. By using Spring Integration’s distributed locking capabilities, the listener attempts to obtain a lock at startup. If it is successful, the task continues. If the task is unable to obtain the lock, the task fails.
Spring Boot provides functionality for executing Spring Batch jobs on startup, which is very convenient. However, if you had a job fail within the scope of a Spring Cloud Task, the task would still be marked as a success because Spring Cloud Task has no way of knowing the job failed (no exception is thrown from the
JobLauncherCommandLineRunner). This release introduces the ability to have a task be marked as failed when the job within the task fails. You can enable this by setting the
spring.cloud.task.batch.failOnJobFailure property to
When Spring Cloud Task was introduced, it would, by default, close the
ApplicationContext programmatically at the completion of the task. This was set as the default because, at the time, if you used Spring Boot’s Acuator, the context wouldn’t shut down on its own. This caused the context to live on forever with no reason to do so.
This default caused another unintended issue. The default project generated by Spring Intializr (https://start.spring.io) includes a unit test that bootstraps the
ApplicationContext and validates that the context loaded. However, since Spring Cloud Task programmatically closes the context once the task is complete, that default test case fails without adding a configuration property.
Spring Boot’s Acuator no longer holds a context open like it did originally, so we have revisited the default value of
spring.cloud.task.closecontext.enable. It is now
true previously). We do not expect this to impact most users, but, if your application required the context to be closed programmatically to shut down, you need to configure this property accordingly.