8. Creating a Simple Stream
Prev | Part III. Streams | Next

## 8. Creating a Simple Stream

The Spring Cloud Data Flow Server exposes a full RESTful API for managing the lifecycle of stream definitions, but the easiest way to use is it is via the Spring Cloud Data Flow shell. Start the shell as described in the Getting Started section.

New streams are created by posting stream definitions. The definitions are built from a simple DSL. For example, let’s walk through what happens if we execute the following shell command:

    dataflow:> stream create --definition "time | log" --name ticktock

This defines a stream named `ticktock` based off the DSL expression `time | log`. The DSL uses the "pipe" symbol `|`, to connect a source to a sink.

Then to deploy the stream execute the following shell command (or alternatively add the `--deploy` flag when creating the stream so that this step is not needed):

    dataflow:> stream deploy --name ticktock

The Admin Server resolves `time` and `log` to maven coordinates and uses those to launch the `time` and `log` applications of the stream. In this simple example, the time source simply sends the current time as a message each second, and the log sink outputs it using the logging framework.

    2016-01-13 10:41:15.398  INFO 65275 --- [nio-9393-exec-1] o.s.c.d.a.s.l.OutOfProcessModuleDeployer : deploying module org.springframework.cloud.stream.module:log-sink:jar:exec:1.0.0.BUILD-SNAPSHOT instance 0
       Logs will be in /var/folders/hs/h87zy7z17qs6mcnl4hj8_dp00000gp/T/spring-cloud-data-flow-3652850284472151116/ticktock.log
    2016-01-13 10:41:15.433  INFO 65275 --- [nio-9393-exec-1] o.s.c.d.a.s.l.OutOfProcessModuleDeployer : deploying module org.springframework.cloud.stream.module:time-source:jar:exec:1.0.0.BUILD-SNAPSHOT instance 0
       Logs will be in /var/folders/hs/h87zy7z17qs6mcnl4hj8_dp00000gp/T/spring-cloud-data-flow-3652850284472151116/ticktock.time

If you would like to have multiple instances of a module in the stream, you can include a property with the deploy command:

    dataflow:> stream deploy --name ticktock --properties "module.time.count=3"

| Important
See Chapter 15, Module Labels.

Prev | Up | Next
7. Introduction | Home | 9. Deleting a Stream