Files
spring-functions-catalog/function/tasklauncher-function
Daniel Frey 724c4ace5f Refactor hardcoded versions in functions submodule branches
This is so they can be updated in a minimal amount of places and leverage the maven hierarchy to propagate them where appropriate.
While working with SNAPSHOT releases of Spring Boot, Spring Integration, and Spring Cloud, it required touching every pom.xml file
in order to reflect the use of the SNAPSHOT. After this change, it will only be required to change the property in the top
functions pom.xml and the versions will reflect to all submodules.

Maven introduced the ability use a key property, revision to propagate this information to the <parent> declarations in each pom.

This was enabled in Maven 3.5+
https://maven.apache.org/maven-ci-friendly.html
2020-10-13 15:15:59 -04:00
..
2020-06-16 18:00:45 -04:00

# TaskLauncher Function

This module provides a `Function` that uses the Data Flow REST client to launch a registered task on a configured https://docs.spring.io/spring-cloud-dataflow/docs/current/reference/htmlsingle/#configuration-local-tasks[task platform].
The client must be configured to connect to a remote Data Flow Server, including any required authentication (see Configuration Options below).

## Beans for injection

You can import the `TaskLauncherFunctionConfiguration` configuration in a Spring Boot application and then inject the following bean.

`taskLauncherFunction`

You may inject this as `TaskLauncherFunction` which implements `Function<LaunchRequest,<Optional<Long>>`.

You can use `taskLauncherFunction` as a qualifier when injecting.

Once injected, you can use the `apply` method of the `Function` to launch a task.
The function takes a link:src/main/java/org/springframework/cloud/fn/tasklauncher/LaunchRequest.java[LaunchRequest] as input.
This is a simple value object that specifies, at a minimum, the name of the task registered in Data Flow.
Optionally, you can pass command line arguments as a `List<String>` and deployment properties as a `Map<String, String>`.
The return value is an `Optional` containing the unique task ID of the launched instance if the launch request is successful.

NOTE: This version of the tasklauncher requires Spring Cloud Data Flow version 2.4.x or higher

## Configuration Options

Specific properties, including the task platform name are prefixed with `tasklauncher`.

For more information on the various options available, please see link:src/main/java/org/springframework/cloud/fn/tasklauncher/TaskLauncherFunctionProperties.java[TaskLauncherFunctionProperties.java]

Data Flow client configuration properties are prefixed with `spring.cloud.dataflow.client`.
Please see https://github.com/spring-cloud/spring-cloud-dataflow/blob/master/spring-cloud-dataflow-rest-client/src/main/java/org/springframework/cloud/dataflow/rest/client/config/DataFlowClientProperties.java[DataFlowClientProperties.java] for more details.

## Examples

See this link:src/test/java/org/springframework/cloud/fn/tasklauncher/TaskLauncherFunctionApplicationTests.java[test suite] for examples of how this function is used.

## Other usage

See this link:../../../applications/sink/tasklauncher-sink/README.adoc[README] where this function is used to create a Spring Cloud Stream application to submit task launch requests.