SCT-12 Creates the SCSt sink that can launch tasks.

resolves  spring-cloud/spring-cloud-task#12
This commit is contained in:
Glenn Renfro
2016-03-02 15:12:18 -05:00
committed by Michael Minella
parent f35f8ef52d
commit aad0a0b1ee
33 changed files with 2154 additions and 2 deletions

View File

@@ -209,3 +209,53 @@ marking the final state of the task.
}
```
=== Launching a task from a Spring Cloud Stream
Allows a user to launch tasks from a stream. This is done by creating a sink that
listens for a message that contains a `TaskLaunchRequest` as its payload. The
TaskLaunchRequest contains the maven coordinates to the Task that is to be executed. It
also has a Map that contains the environment variables that will be used by the Task.
NOTE: If the payload is of a different type then the sink will throw an exception.
For example a stream can be created that has a processor that takes in data from a
http source and creates a `GenericMessage` that contains the `TaskLaunchRequest` and sends
the message to its output channel. The task sink would then receive the message from its
input channnel and then launch the task.
To create a taskSink a user needs to only create a spring boot app that includes the
following annotation `EnableTaskLauncher`. The code would look something like this:
```
@SpringBootApplication
@EnableTaskLauncher
public class TaskSinkApplication {
public static void main(String[] args) {
SpringApplication.run(TaskSinkApplication.class, args);
}
}
```
A sample Sink and Processor have been made available to you in the samples module
of the Spring Cloud Task project. To install these samples into your local maven
repository execute a maven build from the `spring-cloud-task-samples` directory with the
property `skipInstall` set to false. For example:
`mvn clean install -DskipInstall=false`.
==== Spring Cloud Data Flow
To create a stream in Spring Cloud Data Flow first we would want to register the Task Sink
Application we created. In the example below we are registering the Processor and Sink
sample applications using the Spring Cloud Data Flow shell:
```
module register --name taskSink --type sink --coordinates io.spring:tasksink:1.0.0.BUILD-SNAPSHOT
module register --name taskProcessor --type processor --coordinates io.spring:taskprocessor:1.0.0.BUILD-SNAPSHOT
```
To create a stream from the Spring Cloud Data Flow shell would look like this:
```
stream create foo --definition "http --server.port=9000|taskProcessor|taskSink" --deploy
```