Spring Cloud Dataflow Reference
Spring Cloud Dataflow Reference
1.2.0.M3
Sabby Anandan, Marius Bogoevici, Eric Bottard, Mark Fisher, Ilayaperumal Gopinathan, Gunnar Hillert,
Mark Pollack, Patrick Peralta, Glenn Renfro, Thomas Risberg, Dave Syer, David Turanski, Janne Valkealahti
Copyright © 2013-2016 Pivotal Software, Inc.
Copies of this document may be made for your own use and for distribution to others, provided that you do not charge any fee
for such copies and further provided that each copy contains this Copyright Notice, whether distributed in print or electronically.
Spring Cloud Data Flow Reference Guide
Table of Contents
I. Preface .................................................................................................................................... 1
1. About the documentation ................................................................................................ 2
2. Getting help .................................................................................................................... 3
II. Spring Cloud Data Flow Overview ........................................................................................... 4
3. Introducing Spring Cloud Data Flow ................................................................................. 5
3.1. Features .............................................................................................................. 5
III. Architecture ........................................................................................................................... 6
4. Introduction ..................................................................................................................... 7
5. Microservice Architectural Style ....................................................................................... 9
5.1. Comparison to other Platform architectures ........................................................... 9
6. Streaming Applications .................................................................................................. 11
6.1. Imperative Programming Model ........................................................................... 11
6.2. Functional Programming Model ........................................................................... 11
7. Streams ........................................................................................................................ 12
7.1. Topologies ......................................................................................................... 12
7.2. Concurrency ....................................................................................................... 12
7.3. Partitioning ......................................................................................................... 12
7.4. Message Delivery Guarantees ............................................................................ 13
8. Analytics ....................................................................................................................... 15
9. Task Applications .......................................................................................................... 16
10. Data Flow Server ........................................................................................................ 17
10.1. Endpoints ......................................................................................................... 17
10.2. Customization ................................................................................................... 17
10.3. Security ............................................................................................................ 18
11. Runtime ...................................................................................................................... 19
11.1. Fault Tolerance ................................................................................................ 19
11.2. Resource Management ..................................................................................... 19
11.3. Scaling at runtime ............................................................................................ 19
11.4. Application Versioning ...................................................................................... 19
IV. Getting started ..................................................................................................................... 20
12. System Requirements ................................................................................................. 21
13. Deploying Spring Cloud Data Flow Local Server ........................................................... 22
13.1. Maven Configuration ......................................................................................... 23
14. Application Configuration ............................................................................................. 24
V. Server Configuration ............................................................................................................. 25
15. Feature Toggles .......................................................................................................... 26
16. Database Configuration ............................................................................................... 27
17. Security ...................................................................................................................... 28
17.1. Enabling HTTPS ............................................................................................... 28
Using Self-Signed Certificates ............................................................................ 28
Self-Signed Certificates and the Shell ................................................................ 29
17.2. Basic Authentication ......................................................................................... 30
File based authentication ................................................................................... 30
LDAP Authentication ......................................................................................... 31
LDAP Transport Security ........................................................................... 32
Customizing authorization .................................................................................. 33
Authorization - Shell and Dashboard Behavior .................................................... 35
Copies of this document may be made for your own use and for distribution to others, provided that
you do not charge any fee for such copies and further provided that each copy contains this Copyright
Notice, whether distributed in print or electronically.
2. Getting help
Having trouble with Spring Cloud Data Flow, We’d like to help!
Note
All of Spring Cloud Data Flow is open source, including the documentation! If you find problems
with the docs; or if you just want to improve them, please get involved.
Spring Cloud Data Flow is the cloud native redesign of Spring XD – a project that aimed to simplify
development of Big Data applications. The stream and batch modules from Spring XD are refactored
as Spring Boot based stream and task/batch microservice applications respectively. These applications
are now autonomous deployment units and they can "natively" run in modern runtimes such as Cloud
Foundry, Apache YARN, Apache Mesos, and Kubernetes.
Spring Cloud Data Flow offers a collection of patterns and best practices for microservices-based
distributed streaming and task/batch data pipelines.
3.1 Features
• Develop using DSL, REST-APIs, Dashboard, and the drag-and-drop GUI - Flo
• Build data pipelines rapidly using the out-of-the-box stream and task/batch applications
• Take advantage of metrics, health checks, and the remote management of each microservice
application
4. Introduction
Spring Cloud Data Flow simplifies the development and deployment of applications focused on data
processing use-cases. The major concepts of the architecture are Applications, the Data Flow Server,
and the target runtime.
• Long lived Stream applications where an unbounded amount of data is consumed or produced via
messaging middleware.
• Short lived Task applications that process a finite set of data and then terminate.
• Spring Boot uber-jar that is hosted in a maven repository, file, http or any other Spring resource
implementation.
• Docker
The runtime is the place where applications execute. The target runtimes for applications are platforms
that you may already be using for other application deployments.
• Cloud Foundry
• Apache YARN
• Kubernetes
• Apache Mesos
There is a deployer Service Provider Interface (SPI) that enables you to extend Data Flow to deploy
onto other runtimes, for example to support Docker Swarm. There are community implementations of
Hashicorp’s Nomad and RedHat Openshift is available. We look forward to working with the community
for further contributions!
The component that is responsible for deploying applications to a runtime is the Data Flow Server. There
is a Data Flow Server executable jar provided for each of the target runtimes. The Data Flow server
is responsible for interpreting
• A stream DSL that describes the logical flow of data through multiple applications.
• A deployment manifest that describes the mapping of applications onto the runtime. For example, to
set the initial number of instances, memory requirements, and data partitioning.
As an example, the DSL to describe the flow of data from an http source to an Apache Cassandra sink
would be written as “http | cassandra”. These names in the DSL are registered with the Data Flow Server
and map onto application artifacts that can be hosted in Maven or Docker repositories. Many source,
processor, and sink applications for common use-cases (e.g. jdbc, hdfs, http, router) are provided by
the Spring Cloud Data Flow team. The pipe symbol represents the communication between the two
applications via messaging middleware. The two messaging middleware brokers that are supported are
• Apache Kafka
• RabbitMQ
In the case of Kafka, when deploying the stream, the Data Flow server is responsible to create the topics
that correspond to each pipe symbol and configure each application to produce or consume from the
topics so the desired flow of data is achieved.
In this diagram a DSL description of a stream is POSTed to the Data Flow Server. Based on the
mapping of DSL application names to Maven and Docker artifacts, the http-source and cassandra-sink
applications are deployed on the target runtime.
Both Streaming and Task based microservice applications build upon Spring Boot as the foundational
library. This gives all microservice applications functionality such as health checks, security, configurable
logging, monitoring and management functionality, as well as executable JAR packaging.
It is important to emphasise that these microservice applications are ‘just apps’ that you can run
by yourself using ‘java -jar’ and passing in appropriate configuration properties. We provide many
common microservice applications for common operations so you don’t have to start from scratch when
addressing common use-cases which build upon the rich ecosystem of Spring Projects, e.g Spring
Integration, Spring Data, Spring Hadoop and Spring Batch. Creating your own microservice application
is similar to creating other Spring Boot applications, you can start using the Spring Initialzr web site or
the UI to create the basic scaffolding of either a Stream or Task based microservice.
In addition to passing in the appropriate configuration to the applications, the Data Flow server is
responsible for preparing the target platform’s infrastructure so that the application can be deployed. For
example, in Cloud Foundry it would be binding specified services to the applications and executing the
‘cf push’ command for each application. For Kubernetes it would be creating the replication controller,
service, and load balancer.
The Data Flow Server helps simplify the deployment of multiple applications onto a target runtime, but
one could also opt to deploy each of the microservice applications manually and not use Data Flow at
all. This approach might be more appropriate to start out with for small scale deployments, gradually
adopting the convenience and consistency of Data Flow as you develop more applications. Manual
deployment of Stream and Task based microservices is also a useful educational exercise that will help
you better understand some of the automatic applications configuration and platform targeting steps
that the Data Flow Server provides.
Similarly, Apache Storm, Hortonworks DataFlow and Spring Cloud Data Flow’s predecessor, Spring
XD, use a dedicated application execution cluster, unique to each product, that determines where your
code should execute on the cluster and perform health checks to ensure that long lived applications are
restarted if they fail. Often, framework specific interfaces are required to be used in order to correctly
“plug in” to the cluster’s execution framework.
As we discovered during the evolution of Spring XD, the rise of multiple container frameworks in
2015 made creating our own runtime a duplication of efforts. There is no reason to build your own
resource management mechanics, when there are multiple runtime platforms that offer this functionality
already. Taking these considerations into account is what made us shift to the current architecture
where we delegate the execution to popular runtimes, runtimes that you may already be using for other
purposes. This is an advantage in that it reduces the cognitive distance for creating and managing data
centric applications as many of the same skills used for deploying other end-user/web applications are
applicable.
6. Streaming Applications
While Spring Boot provides the foundation for creating DevOps friendly microservice applications,
other libraries in the Spring ecosystem help create Stream based microservice applications. The most
important of these is Spring Cloud Stream.
The essence of the Spring Cloud Stream programming model is to provide an easy way to describe
multiple inputs and outputs of an application that communicate over messaging middleware. These input
and outputs map onto Kafka topics or Rabbit exchanges and queues. Common application configuration
for a Source that generates data, a Process that consumes and produces data and a Sink that consumes
data is provided as part of the library.
@EnableBinding(Sink.class)
public class LoggingSink {
@StreamListener(Sink.INPUT)
public void log(String message) {
System.out.println(message);
}
}
In this case the String payload of a message coming on the input channel, is handed to the log method.
The @EnableBinding annotation is what is used to tie together the input channel to the external
middleware.
7. Streams
7.1 Topologies
The Stream DSL describes linear sequences of data flowing through the system. For example, in the
stream definition http | transformer | cassandra, each pipe symbol connects the application
on the left to the one on the right. Named channels can be used for routing and to fan out data to multiple
messaging destinations.
Taps can be used to ‘listen in’ to the data that if flowing across any of the pipe symbols. Taps can be
used as sources for new streams with an in independent life cycle.
7.2 Concurrency
For an application that will consume events, Spring Cloud stream exposes a concurrency setting that
controls the size of a thread pool used for dispatching incoming messages. See the Consumer properties
documentation for more information.
7.3 Partitioning
A common pattern in stream processing is to partition the data as it moves from one application to
the next. Partitioning is a critical concept in stateful processing, for either performance or consistency
reasons, to ensure that all related data is processed together. For example, in a time-windowed average
calculation example, it is important that all measurements from any given sensor are processed by the
same application instance. Alternatively, you may want to cache some data related to the incoming
events so that it can be enriched without making a remote procedure call to retrieve the related data.
Spring Cloud Data Flow supports partitioning by configuring Spring Cloud Stream’s output and input
bindings. Spring Cloud Stream provides a common abstraction for implementing partitioned processing
use cases in a uniform fashion across different types of middleware. Partitioning can thus be used
whether the broker itself is naturally partitioned (e.g., Kafka topics) or not (e.g., RabbitMQ). The following
image shows how data could be partitioned into two buckets, such that each instance of the average
processor application consumes a unique set of data.
To use a simple partitioning strategy in Spring Cloud Data Flow, you only need set the instance count for
each application in the stream and a partitionKeyExpression producer property when deploying
the stream. The partitionKeyExpression identifies what part of the message will be used as the
key to partition data in the underlying middleware. An ingest stream can be defined as http |
averageprocessor | cassandra (Note that the Cassandra sink isn’t shown in the diagram above).
Suppose the payload being sent to the http source was in JSON format and had a field called sensorId.
Deploying the stream with the shell command stream deploy ingest --propertiesFile
ingestStream.properties where the contents of the file ingestStream.properties are
deployer.http.count=3
deployer.averageprocessor.count=2
app.http.producer.partitionKeyExpression=payload.sensorId
will deploy the stream such that all the input and output destinations are configured for data to
flow through the applications but also ensure that a unique set of data is always delivered to each
averageprocessor instance. In this case the default algorithm is to evaluate payload.sensorId %
partitionCount where the partitionCount is the application count in the case of RabbitMQ and
the partition count of the topic in the case of Kafka.
Please refer to the section called “Passing stream partition properties during stream deployment” for
additional strategies to partition streams during deployment and how they map onto the underlying
Spring Cloud Stream Partitioning properties.
Also note, that you can’t currently scale partitioned streams. Read the section Section 11.3, “Scaling
at runtime” for more information.
The Binder abstraction in Spring Cloud Stream is what connects the application to the middleware. There
are several configuration properties of the binder that are portable across all binder implementations
and some that are specific to the middleware.
For consumer applications there is a retry policy for exceptions generated during message
handling. The retry policy is configured using the common consumer properties maxAttempts,
backOffInitialInterval, backOffMaxInterval, and backOffMultiplier. The default
values of these properties will retry the callback method invocation 3 times and wait one second for the
first retry. A backoff multiplier of 2 is used for the second and third attempts.
When the number of retry attempts has exceeded the maxAttempts value, the exception and the failed
message will become the payload of a message and be sent to the application’s error channel. By
default, the default message handler for this error channel logs the message. You can change the default
behavior in your application by creating your own message handler that subscribes to the error channel.
Spring Cloud Stream also supports a configuration option for both Kafka and RabbitMQ binder
implementations that will send the failed message and stack trace to a dead letter queue. The dead letter
queue is a destination and its nature depends on the messaging middleware (e.g in the case of Kafka it
is a dedicated topic). To enable this for RabbitMQ set the consumer properties republishtoDlq and
autoBindDlq and the producer property autoBindDlq to true when deploying the stream. To always
apply these producer and consumer properties when deploying streams, configure them as common
application properties when starting the Data Flow server.
Additional messaging delivery guarantees are those provided by the underlying messaging middleware
that is chosen for the application for both producing and consuming applications. Refer to the Kafka
Consumer and Producer and Rabbit Consumer and Producer documentation for more details. You will
find extensive declarative support for all the native QOS options.
8. Analytics
Spring Cloud Data Flow is aware of certain Sink applications that will write counter data to Redis and
provides an REST endpoint to read counter data. The types of counters supported are
• Counter - Counts the number of messages it receives, optionally storing counts in a separate store
such as redis.
• Field Value Counter - Counts occurrences of unique values for a named field in a message payload
• Aggregate Counter - Stores total counts but also retains the total count values for each minute, hour
day and month.
It is important to note that the timestamp that is used in the aggregate counter can come from a field in
the message itself so that out of order messages are properly accounted.
9. Task Applications
The Spring Cloud Task programming model provides:
• Emit task events to a stream (as a source) during the task lifecycle.
10.2 Customization
Each Data Flow Server executable jar targets a single runtime by delegating to the implementation of
the deployer Service Provider Interface found on the classpath.
We provide a Data Flow Server executable jar that targets a single runtime. The Data Flow server
delegates to the implementation of the deployer Service Provider Interface found on the classpath. In
the current version, there are no endpoints specific to a target runtime, but may be available in future
releases as a convenience to access runtime specific features
While we provide a server executable for each of the target runtimes you can also create your own
customized server application using Spring Initialzr. This let’s you add or remove functionality relative
to the executable jar we provide. For example, adding additional security implementations, custom
endpoints, or removing Task or Analytics REST endpoints. You can also enable or disable some features
through the use of feature toggles.
10.3 Security
The Data Flow Server executable jars support basic http, LDAP(S), File-based, and OAuth 2.0
authentication to access its endpoints. Refer to the security section for more information.
11. Runtime
11.1 Fault Tolerance
The target runtimes supported by Data Flow all have the ability to restart a long lived application should
it fail. Spring Cloud Data Flow sets up whatever health probe is required by the runtime environment
when deploying the application.
The collective state of all applications that comprise the stream is used to determine the state of the
stream. If an application fails, the state of the stream will change from ‘deployed’ to ‘partial’.
Currently, this is not supported with the Kafka binder (based on the 0.8 simple consumer at the time
of the release), as well as partitioned streams, for which the suggested workaround is redeploying
the stream with an updated number of instances. Both cases require a static consumer set up based
on information about the total instance count and current instance index, a limitation intended to be
addressed in future releases. For example, Kafka 0.9 and higher provides good infrastructure for scaling
applications dynamically and will be available as an alternative to the current Kafka 0.8 based binder
in the near future. One specific concern regarding scaling partitioned streams is the handling of local
state, which is typically reshuffled as the number of instances is changed. This is also intended to be
addressed in the future versions, by providing first class support for local state management.
The roadmap for Spring Cloud Data Flow will deploy applications that are compatible with Spinnaker
to manage the complete application lifecycle. This also includes automated canary analysis backed by
application metrics. Portable commands in the Data Flow server to trigger pipelines in Spinnaker are
also planned.
You need to have an RDBMS for storing stream, task and app states in the database. The local Data
Flow server by default uses embedded H2 database for this.
You also need to have Redis running if you are running any streams that involve analytics applications.
Redis may also be required run the unit/integration tests.
For the deployed streams and tasks to communicate, either RabbitMQ or Kafka needs to be installed.
wget http://repo.spring.io/milestone/org/springframework/cloud/spring-cloud-dataflow-server-
local/1.2.0.M3/spring-cloud-dataflow-server-local-1.2.0.M3.jar
wget http://repo.spring.io/milestone/org/springframework/cloud/spring-cloud-dataflow-shell/1.2.0.M3/
spring-cloud-dataflow-shell-1.2.0.M3.jar
a. Since the Data Flow Server is a Spring Boot application, you can run it just by using java -jar.
If the Data Flow Server and shell are not running on the same host, point the shell to the Data Flow
server URL:
By default, the application registry will be empty. If you would like to register all out-of-the-box stream
applications built with the Kafka binder in bulk, you can with the following command. For more details,
review how to register applications.
Note
Depending on your environment, you may need to configure the Data Flow Server to point to
a custom Maven repository location or configure proxy settings. See Section 13.1, “Maven
Configuration” for more information.
4. You can now use the shell commands to list available applications (source/processors/sink) and
create streams. For example:
dataflow:> stream create --name httptest --definition "http --server.port=9000 | log" --deploy
Note
You will need to wait a little while until the apps are actually deployed successfully before
posting data. Look in the log file of the Data Flow server for the location of the log files for
the http and log applications. Tail the log file for each application to verify the application
has started.
Look to see if hello world ended up in log files for the log application.
Note
When deploying locally, each app (and each app instance, in case of count>1) gets a
dynamically assigned server.port unless you explicitly assign one with --server.port=x.
In both cases, this setting is propagated as a configuration property that will override any lower-
level setting that you may have used (e.g. in application.yml files).
Tip
In case you encounter unexpected errors when executing shell commands, you can retrieve
more detailed error information by setting the exception logging level to WARNING in
logback.xml:
By default, the protocol is set to http. You can omit the auth properties if the proxy doesn’t need a
username and password.
If you want to pass these properties as environment properties, then you need to use
SPRING_APPLICATION_JSON to set these properties and pass SPRING_APPLICATION_JSON as
environment variable as below:
When deploying the application you can also set deployer properties prefixed with deployer.<name
of application>, So for example to set Java options for the time application in the ticktock
stream, use the following stream deployment properties.
As a convenience you can set the property deployer.memory to set the Java option -Xmx. So for
example,
1. Streams
2. Tasks
3. Analytics
One can enable, disable these features by setting the following boolean properties when launching the
Data Flow server:
• spring.cloud.dataflow.features.streams-enabled
• spring.cloud.dataflow.features.tasks-enabled
• spring.cloud.dataflow.features.analytics-enabled
By default, all the features are enabled. Note: Since analytics feature is enabled by default, the Data
Flow server is expected to have a valid Redis store available as analytic repository as we provide a
default implementation of analytics based on Redis. This also means that the Data Flow server’s health
depends on the redis store availability as well. If you do not want to enabled HTTP endpoints to read
analytics data written to Redis, then disable the analytics feature using the property mentioned above.
The JDBC drivers for MySQL (via MariaDB driver), HSQLDB, PostgreSQL along with embedded H2
are available out of the box. If you are using any other database, then the corresponding JDBC driver
jar needs to be on the classpath of the server.
The database properties can be passed as command-line arguments to the Data Flow Server.
For PostgreSQL:
For HSQLDB:
Note
There is a schema update to the Spring Cloud Data Flow datastore when upgrading from version
1.0.x to 1.1.x. Migration scripts for specific database types can be found here.
Note
If you wish to use an external H2 database instance instead of the one embedded with Spring
Cloud Data Flow set the spring.dataflow.embedded.database.enabled property to
false. If spring.dataflow.embedded.database.enabled is set to false or a database
other than h2 is specified as the datasource the embedded database will not start.
17. Security
By default, the Data Flow server is unsecured and runs on an unencrypted HTTP connection. You can
secure your REST endpoints, as well as the Data Flow Dashboard by enabling HTTPS and requiring
clients to authenticate using either:
• OAuth 2.0
• Basic Authentication
NOTE: By default, the REST endpoints (administration, management and health), as well as the
Dashboard UI do not require authenticated access.
server:
port: 8443 ❶
ssl:
key-alias: yourKeyAlias ❷
key-store: path/to/keystore ❸
key-store-password: yourKeyStorePassword ❹
key-password: yourKeyPassword ❺
trust-store: path/to/trust-store ❻
trust-store-password: yourTrustStorePassword ❼
❶ As the default port is 9393, you may choose to change the port to a more common HTTPs-typical
port.
❷ The alias (or name) under which the key is stored in the keystore.
❸ The path to the keystore file. Classpath resources may also be specified, by using the classpath
prefix: classpath:path/to/keystore
❹ The password of the keystore.
❺ The password of the key.
❻ The path to the truststore file. Classpath resources may also be specified, by using the classpath
prefix: classpath:path/to/trust-store
❼ The password of the trust store.
Note
If HTTPS is enabled, it will completely replace HTTP as the protocol over which the REST
endpoints and the Data Flow Dashboard interact. Plain HTTP requests will fail - therefore, make
sure that you configure your Shell accordingly.
For testing purposes or during development it might be convenient to create self-signed certificates. To
get started, execute the following command to create a certificate:
❶ CN is the only important parameter here. It should match the domain you are trying to access,
e.g. localhost.
server:
port: 8443
ssl:
enabled: true
key-alias: dataflow
key-store: "/your/path/to/dataflow.keystore"
key-store-type: jks
key-store-password: dataflow
key-password: dataflow
This is all that’s needed for the Data Flow Server. Once you start the server, you should be able to
access it via https://localhost:8443/. As this is a self-signed certificate, you will hit a warning in your
browser, that you need to ignore.
By default self-signed certificates are an issue for the Shell and additional steps are necessary to make
the Shell work with self-signed certificates. Two options are available:
In order to use the JVM truststore option, we need to export the previously created certificate from the
keystore:
$ keytool -export -alias dataflow -keystore dataflow.keystore -file dataflow_cert -storepass dataflow
Now, you are ready to launch the Data Flow Shell using the following JVM arguments:
$ java -Djavax.net.ssl.trustStorePassword=dataflow \
-Djavax.net.ssl.trustStore=/path/to/dataflow.truststore \
-Djavax.net.ssl.trustStoreType=jks \
-jar spring-cloud-dataflow-shell-1.2.0.M3.jar
Tip
In case you run into trouble establishing a connection via SSL, you can enable additional logging
by using and setting the javax.net.debug JVM argument to ssl.
Alternatively, you can also bypass the certification validation by providing the optional command-line
parameter --dataflow.skip-ssl-validation=true.
Using this command-line parameter, the shell will accept any (self-signed) SSL certificate.
Warning
If possible you should avoid using this option. Disabling the trust manager defeats the purpose
of SSL and makes you vulnerable to man-in-the-middle attacks.
security:
basic:
enabled: true ❶
realm: Spring Cloud Data Flow ❷
Note
Current versions of Chrome do not display the realm. Please see the following Chromium issue
ticket for more information.
In this use-case, the underlying Spring Boot will auto-create a user called user with an auto-generated
password which will be printed out to the console upon startup.
Note
Please be aware of inherent issues of Basic Authentication and logging out, since the credentials
are cached by the browser and simply browsing back to application pages will log you back in.
If you need to define more than one file-based user account, please take a look at File based
authentication.
security:
basic:
enabled: true
Important
As of Spring Cloud Data Flow 1.1, roles are not supported, yet (specified roles are ignored).
Due to an issue in Spring Security, though, at least one role must be provided.
LDAP Authentication
Spring Cloud Data Flow also supports authentication against an LDAP server (Lightweight Directory
Access Protocol), providing support for the following 2 modes:
• Direct bind
When the LDAP authentication option is activated, the default single user mode is turned off.
In direct bind mode, a pattern is defined for the user’s distinguished name (DN), using a placeholder for
the username. The authentication process derives the distinguished name of the user by replacing the
placeholder and use it to authenticate a user against the LDAP server, along with the supplied password.
You can set up LDAP direct bind as follows:
security:
basic:
enabled: true
realm: Spring Cloud Data Flow
spring:
cloud:
dataflow:
security:
authentication:
ldap:
enabled: true ❶
url: ldap://ldap.example.com:3309 ❷
userDnPattern: uid={0},ou=people,dc=example,dc=com ❸
The search and bind mode involves connecting to an LDAP server, either anonymously or with a fixed
account, and searching for the distinguished name of the authenticating user based on its username,
and then using the resulting value and the supplied password for binding to the LDAP server. This option
is configured as follows:
security:
basic:
enabled: true
realm: Spring Cloud Data Flow
spring:
cloud:
dataflow:
security:
authentication:
ldap:
enabled: true ❶
url: ldap://localhost:10389 ❷
managerDn: uid=admin,ou=system ❸
managerPassword: secret ❹
userSearchBase: ou=otherpeople,dc=example,dc=com ❺
userSearchFilter: uid={0} ❻
Tip
For more information, please also see the chapter LDAP Authentication of the Spring Security
reference guide.
When connecting to an LDAP server, you typically (In the LDAP world) have 2 options in order to
establish a connection to an LDAP server securely:
As of Spring Cloud Data Flow 1.1.0 only LDAPs is supported out-of-the-box. When using official
certificates no special configuration is necessary, in order to connect to an LDAP Server via LDAPs.
Just change the url format to ldaps, e.g. ldaps://localhost:636.
In case of using self-signed certificates, the setup for your Spring Cloud Data Flow server becomes
slightly more complex. The setup is very similar to the section called “Using Self-Signed Certificates”
(Please read first) and Spring Cloud Data Flow needs to reference a trustStore in order to work with
your self-signed certificates.
Important
While useful during development and testing, please never use self-signed certificates in
production!
Ultimately you have to provide a set of system properties to reference the trustStore and its credentials
when starting the server:
$ java -Djavax.net.ssl.trustStorePassword=dataflow \
-Djavax.net.ssl.trustStore=/path/to/dataflow.truststore \
-Djavax.net.ssl.trustStoreType=jks \
-jar spring-cloud-starter-dataflow-server-local-1.2.0.M3.jar
As mentioned above, another option to connect to an LDAP server securely is via Start TLS. In the LDAP
world, LDAPs is technically even considered deprecated in favor of Start TLS. However, this option is
currently not supported out-of-the-box by Spring Cloud Data Flow.
Please follow the following issue tracker ticket to track its implementation. You may also want to look
at the Spring LDAP reference documentation chapter on Custom DirContext Authentication Processing
for further details.
Customizing authorization
All of the above deals with authentication, i.e. how to assess the identity of the user. Irrespective of the
option chosen, you can also customize authorization i.e. who can do what.
The default scheme uses three roles to protect the REST endpoints that Spring Cloud Data Flow
exposes:
• ROLE_CREATE for anything that involves creating, deleting or mutating the state of the system
spring:
cloud:
dataflow:
security:
authorization:
enabled: true
rules:
# Metrics
# Boot Endpoints
# Apps
# Completions
# Job Executions & Batch Job Execution Steps && Job Step Execution Progress
# Running Applications
# Stream Definitions
# Stream Deployments
# Task Definitions
# Task Executions
where
• each of those separated by one or several blank characters (spaces, tabs, etc.)
Be mindful that the above is indeed a YAML list, not a map (thus the use of '-' dashes at the start of each
line) that lives under the spring.cloud.dataflow.security.authorization.rules key.
Tip
In case you are solely interested in authentication but not authorization, for instance
every user shall have have access to all endpoints, then you can also set
spring.cloud.dataflow.security.authorization.enabled=false.
When authorization is enabled, the Dashboard and the Shell will be role-aware, meaning that depending
on the assigned role(s), not all functionality may be visible.
For instance, Shell commands, for which the user does not have the necessary roles for, will be marked
as unavailable.
Important
Currently, the Shell’s help command will list commands that are unavailable. Please track the
following issue: github.com/spring-projects/spring-shell/issues/115
Similarly for the Dashboard, the UI will not show pages, or page elements, for which the user is not
authorized for.
When configuring Ldap for authentication, you can also specify the group-role-attribute in
conjunction with group-search-base and group-search-filter.
The group role attribure contains the name of the role. If not specified, the ROLE_MANAGE role is
populated by default.
For further information, please refer to Configuring an LDAP Server of the Spring Security reference
guide.
• Authorization Code - Used for the GUI (Browser) integration. You will be redirected to your OAuth
Service for authentication
• Password - Used by the shell (And the REST integration), so you can login using username and
password
The REST endpoints are secured via Basic Authentication but will use the Password Grand Type under
the covers to authenticate with your OAuth2 service.
Note
When authentication is set up, it is strongly recommended to enable HTTPS as well, especially
in production environments.
You can turn on OAuth2 authentication by adding the following to application.yml or via
environment variables:
security:
basic:
enabled: true ❶
realm: Spring Cloud Data Flow ❷
oauth2: ❸
client:
client-id: myclient
client-secret: mysecret
access-token-uri: http://127.0.0.1:9999/oauth/token
user-authorization-uri: http://127.0.0.1:9999/oauth/authorize
resource:
user-info-uri: http://127.0.0.1:9999/me
Note
As of the current version, Spring Cloud Data Flow does not provide finer-grained authorization
when OAUTH is used as authentication mechanism. Thus, once you are logged in, you have
full access to all functionality.
You can verify that basic authentication is working properly using curl:
If your OAuth2 provider supports the Password Grant Type you can start the Data Flow Shell with:
Note
Keep in mind that when authentication for Spring Cloud Data Flow is enabled, the underlying
OAuth2 provider must support the Password OAuth2 Grant Type, if you want to use the Shell.
From within the Data Flow Shell you can also provide credentials using:
#####################################################
#Credentials#[username='my_username, password=****']#
#####################################################
#Result # #
#Target #http://localhost:9393 #
#####################################################
With Spring Security OAuth you can easily create your own OAuth2 Server with the following 2 simple
annotations:
• @EnableResourceServer
• @EnableAuthorizationServer
https://github.com/ghillert/oauth-test-server/
Simply clone the project, built and start it. Furthermore configure Spring Cloud Data Flow with the
respective Client Id and Client Secret.
If you rather like to use an existing OAuth2 provider, here is an example for GitHub. First you need to
Register a new application under your GitHub account at:
https://github.com/settings/developers
When running a default version of Spring Cloud Data Flow locally, your GitHub configuration should
look like the following:
Note
For the Authorization callback URL you will enter Spring Cloud Data Flow’s Login URL, e.g.
localhost:9393/login.
Configure Spring Cloud Data Flow with the GitHub relevant Client Id and Secret:
security:
basic:
enabled: true
oauth2:
client:
client-id: your-github-client-id
client-secret: your-github-client-secret
access-token-uri: https://github.com/login/oauth/access_token
user-authorization-uri: https://github.com/login/oauth/authorize
resource:
user-info-uri: https://api.github.com/user
Important
GitHub does not support the OAuth2 password grant type. As such you cannot use the Spring
Cloud Data Flow Shell in conjunction with GitHub.
management:
contextPath: /management
security:
enabled: true
Important
If you don’t explicitly enable security for the management endpoints, you may end up having
unsecured REST endpoints, despite security.basic.enabled being set to true.
The Actuator library adds http endpoints under the context path /management that is also a discovery
page for available endpoints. For example, there is a health endpoint that shows application health
information and an env that lists properties from Spring’s ConfigurableEnvironment. By default
only the health and application info endpoints are accessible. The other endpoints are considered to
be sensitive and need to be enabled explicitly via configuration. If you are enabling sensitive endpoints
then you should also secure the Data Flow server’s endpoints so that information is not inadvertently
exposed to unauthenticated users. The local Data Flow server has security disabled by default, so all
actuator endpoints are available.
The Data Flow server requires a relational database and if the feature toggled for analytics is enabled,
a Redis server is also required. The Data Flow server will autoconfigure the DataSourceHealthIndicator
and RedisHealthIndicator if needed. The health of these two services is incorporated to the overall health
status of the server through the health endpoint.
An easy way to include the client library into the Data Flow server is to create a new Data Flow Server
project from start.spring.io. Type 'flow' in the "Search for dependencies" text box and select the server
runtime you want to customize. A simple way to have the Spring Cloud Data Flow server be a client
to the Spring Boot Admin Server is by adding a dependency to the Data Flow server’s pom and an
additional configuration property as documented in Registering Client Applications.
This will result in a UI with tabs for each of the actuator endpoints.
Additional configuration is required to interact with JMX beans and logging levels. Refer to the Spring
Boot admin documentation for more information. As only the info and health endpoints are available
to unauthenticated users, you should enable security on the Data Flow Server and also configure Spring
Boot Admin server’s security so that it can securely access the actuator endpoints.
In particular, the metrics endpoint contains counters and gauges for HTTP requests, System Metrics
(such as JVM stats), DataSource Metrics and Message Channel Metrics (such as message rates). In
turn, these metrics can be exported periodically to various application monitoring tools via MetricWriter
implementations. You can control how often and which Spring Boot metrics are exported through the
use of include and exclude name filters.
The project Spring Cloud Data Flow Metrics provides the foundation for exporting Spring Boot metrics.
The main project provides Spring Boots AutoConfiguration to setup the exporting process and common
functionality such as defining a metric name prefix appropriate for your environement. For example, you
may want to include the region where the application is running in addition to the application’s name and
stream/task to which it belongs. The main project also includes a LogMetricWriter so that metrics
can be stored into the log file. While very simple in approach, log files are often ingested into application
monitoring tools (such as Splunk) where they can be further processed to create dashboards of an
application’s performance.
The project Spring Cloud Data Flow Metrics Datadog Metrics provides integration to export Spring Boot
metrics to Datadog.
To make use of this functionality, you will need to add additional dependencies into your Stream and
Task applications. To customize the "out of the box" Task and Stream applications you can use the
Data Flow Initializr to generate a project and then add to the generated Maven pom file the MetricWriter
implementation you want to use. The documentation on the Data Flow Metrics project pages provides
the additional information you need to get started.
19. Introduction
In Spring Cloud Data Flow, a basic stream defines the ingestion of event data from a source to a sink that
passes through any number of processors. Streams are composed of Spring Cloud Stream applications
and the deployment of stream definitions is done via the Data Flow Server (REST API). The Getting
Started section shows you how to start the server and how to start and use the Spring Cloud Data Flow
shell.
A high level DSL is used to create stream definitions. The DSL to define a stream that has an http source
and a file sink (with no processors) is shown below
http | file
The DSL mimics UNIX pipes and filters syntax. Default values for ports and filenames are used in this
example but can be overridden using -- options, such as
To create these stream definitions you use the shell or make an HTTP POST request to the Spring
Cloud Data Flow Server. For more information on making HTTP request directly to the server, consult
the REST API Guide.
The shell provides tab completion for application properties and also the shell command app info
<appType>:<appName> provides additional documentation for all the supported properties.
Note
When providing a URI with the maven scheme, the format should conform to the following:
maven://<groupId>:<artifactId>[:<extension>[:<classifier>]]:<version>
For example, if you would like to register the snapshot versions of the http and log applications built
with the RabbitMQ binder, you could do the following:
If you would like to register multiple apps at one time, you can store them in a properties file where the
keys are formatted as <type>.<name> and the values are the URIs.
For example, if you would like to register the snapshot versions of the http and log applications built
with the RabbitMQ binder, you could have the following in a properties file [eg: stream-apps.properties]:
source.http=maven://org.springframework.cloud.stream.app:http-source-rabbit:1.1.2.BUILD-SNAPSHOT
sink.log=maven://org.springframework.cloud.stream.app:log-sink-rabbit:1.1.2.BUILD-SNAPSHOT
Then to import the apps in bulk, use the app import command and provide the location of the
properties file via --uri:
For convenience, we have the static files with application-URIs (for both maven and docker) available
for all the out-of-the-box stream and task/batch app-starters. You can point to this file and import all
the application-URIs in bulk. Otherwise, as explained in previous paragraphs, you can register them
individually or have your own custom property file with only the required application-URIs in it. It is
recommended, however, to have a "focused" list of desired application-URIs in a custom property file.
You can find more information about the available task starters in the Task App Starters Project Page
and related reference documentation. For more information about the available stream starters look at
the Stream App Starters Project Page and related reference documentation.
As an example, if you would like to register all out-of-the-box stream applications built with the RabbitMQ
binder in bulk, you can with the following command.
You can also pass the --local option (which is true by default) to indicate whether the properties file
location should be resolved within the shell process itself. If the location should be resolved from the
Data Flow Server process, specify --local false.
When using either app register or app import, if a stream app is already registered with the
provided name and type, it will not be overridden by default. If you would like to override the pre-existing
stream app, then include the --force option.
Note
In some cases the Resource is resolved on the server side, whereas in others the URI will be
passed to a runtime container instance where it is resolved. Consult the specific documentation
of each Data Flow Server for more detail.
the prefix spring.jmx and logging. When creating your own application it is desirable to whitelist
properties so that the shell and the UI can display them first as primary properties when presenting
options via TAB completion or in drop-down boxes.
The Spring Cloud Stream application starters are a good place to look for examples of usage. Here is
a simple example of the file sink’s spring-configuration-metadata-whitelist.properties
file
configuration-properties.classes=org.springframework.cloud.stream.app.file.sink.FileSinkProperties
If we also wanted to add server.port to be white listed, then it would look like this:
configuration-properties.classes=org.springframework.cloud.stream.app.file.sink.FileSinkProperties
configuration-properties.names=server.port
Important
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
Here is the contents of such an artifact, for the canonical log sink:
To help with that (as a matter of fact, you don’t want to try to craft this giant JSON file by hand), you
can use the following plugin in your build:
<plugin>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-app-starter-metadata-maven-plugin</artifactId>
<executions>
<execution>
<id>aggregate-metadata</id>
<phase>compile</phase>
<goals>
<goal>aggregate-metadata</goal>
</goals>
</execution>
</executions>
</plugin>
Note
1. being way lighter (usually a few kilobytes, as opposed to megabytes for the actual app), they are
quicker to download, allowing quicker feedback when using e.g. app info or the Dashboard UI
2. as a consequence of the above, they can be used in resource constrained environments (such as
PaaS) when metadata is the only piece of information needed
3. finally, for environments that don’t deal with boot uberjars directly (for example, Docker-based
runtimes such as Kubernetes or Mesos), this is the only way to provide metadata about the properties
supported by the app.
Remember though, that this is entirely optional when dealing with uberjars. The uberjar itself also
includes the metadata in it already.
Once you have a companion artifact at hand, you need to make the system aware of it so that it can
be used.
When registering a single app via app register, you can use the optional --metadata-uri option
in the shell, like so:
When registering several files using the app import command, the file should contain a
<type>.<name>.metadata line in addition to each <type>.<name> line. This is optional (i.e. if some
apps have it but some others don’t, that’s fine).
Here is an example for a Dockerized app, where the metadata artifact is being hosted in a Maven
repository (but retrieving it via http:// or file:// would be equally possible).
...
source.http=docker:springcloudstream/http-source-rabbit:latest
source.http.metadata=maven://org.springframework.cloud.stream.app:http-source-
rabbit:jar:metadata:1.2.0.BUILD-SNAPSHOT
...
The process of creating Spring Cloud Stream applications via Spring Initializr is detailed in the Spring
Cloud Stream documentation. It is possible to include multiple binders to an application. If doing so,
refer the instructions in the section called “Passing Spring Cloud Stream properties for the application”
on how to configure them.
For supporting property whitelisting, Spring Cloud Stream applications running in Spring Cloud Data
Flow may include the Spring Boot configuration-processor as an optional dependency, as in the
following example.
<dependencies>
<!-- other dependencies -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
</dependencies>
Note
Make sure that the spring-boot-maven-plugin is included in the POM. The plugin is
necesary for creating the executable jar that will be registered with Spring Cloud Data Flow.
Spring Initialzr will include the plugin in the generated POM.
Once a custom application has been created, it can be registered as described in ???.
New streams are created by with the help of 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:
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):
The Data Flow Server resolves time and log to maven coordinates and uses those to launch the time
and log applications of the stream.
In this example, the time source simply sends the current time as a message each second, and the log
sink outputs it using the logging framework. You can tail the stdout log (which has an "_<instance>"
suffix). The log files are located within the directory displayed in the Data Flow Server’s log output, as
shown above.
$ tail -f /var/folders/wn/8jxm_tbd1vj28c8vj37n900m0000gn/T/spring-cloud-dataflow-912434582726479179/
ticktock-1464788481708/ticktock.log/stdout_0.log
2016-06-01 09:45:11.250 INFO 79194 --- [ kafka-binder-] log.sink : 06/01/16 09:45:11
2016-06-01 09:45:12.250 INFO 79194 --- [ kafka-binder-] log.sink : 06/01/16 09:45:12
2016-06-01 09:45:13.251 INFO 79194 --- [ kafka-binder-] log.sink : 06/01/16 09:45:13
The shell command app info <appType>:<appName> displays the white-listed application
properties for the application. For more info on the property white listing refer to Section 21.1,
“Whitelisting application properties”
Below are the white listed properties for the app time:
Below are the white listed properties for the app log:
The application properties for the time and log apps can be specified at the time of stream creation
as follows:
dataflow:> stream create --definition "time --fixed-delay=5 | log --level=WARN" --name ticktock
Note that the properties fixed-delay and level defined above for the apps time and log are the
'short-form' property names provided by the shell completion. These 'short-form' property names are
applicable only for the white-listed properties and in all other cases, only fully qualified property names
should be used.
The following table recaps the difference in behavior between the two.
Note that count is the reserved property name used by the underlying deployer. Hence, if the
application also has a custom property named count, it is not supported when specified in 'short-
form' form during stream deployment as it could conflict with the instance count deployer property.
Instead, the count as a custom application property can be specified in its fully qualified form (example:
app.foo.bar.count) during stream deployment or it can be specified using 'short-form' or fully
qualified form during the stream creation where it will be considered as an app property.
Important
Inline properties
use the --properties shell option and list properties as a comma separated list of key=value
pairs, like so:
deployer.transform.count=2
app.transform.producer.partitionKeyExpression=payload
Both the above properties will be passed as deployment properties for the stream foo above.
In case of using YAML as the format for the deployment properties, use the .yaml or .yml file extention
when deploying the stream,
deployer:
transform:
count: 2
app:
transform:
producer:
partitionKeyExpression: payload
can be deployed with application properties using the 'short-form' property names:
Spring Cloud Data Flow sets the required Spring Cloud Stream properties for the
applications inside the stream. Most importantly, the spring.cloud.stream.bindings.<input/
output>.destination is set internally for the apps to bind.
If someone wants to override any of the Spring Cloud Stream properties, they can be set via deployment
properties.
if there are multiple binders available in the classpath for each of the applications and the binder is
chosen for each deployment then the stream can be deployed with the specific Spring Cloud Stream
properties as:
Note
Overriding the destination names is not recommended as Spring Cloud Data Flow takes care
of setting this internally.
A Spring Cloud Stream application can have producer and consumer properties set per-binding
basis. While Spring Cloud Data Flow supports specifying short-hand notation for per binding producer
properties such as partitionKeyExpression, partitionKeyExtractorClass as described in
the section called “Passing stream partition properties during stream deployment”, all the supported
Spring Cloud Stream producer/consumer properties can be set as Spring Cloud Stream properties for
the app directly as well.
The consumer properties can be set for the inbound channel name with the prefix app.
[app/label name].spring.cloud.stream.bindings.<channelName>.consumer. and the
producer properties can be set for the outbound channel name with the prefix app.[app/
label name].spring.cloud.stream.bindings.<channelName>.producer.. For example,
the stream
The binder specific producer/consumer properties can also be specified in a similar way.
For instance
app.[app/label name].producer.partitionKeyExtractorClass
The class name of a PartitionKeyExtractorStrategy (default null)
app.[app/label name].producer.partitionKeyExpression
A SpEL expression, evaluated against the message, to determine the partition key; only applies if
partitionKeyExtractorClass is null. If both are null, the app is not partitioned (default null)
app.[app/label name].producer.partitionSelectorClass
The class name of a PartitionSelectorStrategy (default null)
app.[app/label name].producer.partitionSelectorExpression
A SpEL expression, evaluated against the partition key, to determine the partition index to which
the message will be routed. The final partition index will be the return value (an integer) modulo
[nextModule].count. If both the class and expression are null, the underlying binder’s default
PartitionSelectorStrategy will be applied to the key (default null)
In summary, an app is partitioned if its count is > 1 and the previous app has a
partitionKeyExtractorClass or partitionKeyExpression (class takes precedence).
When a partition key is extracted, the partitioned app instance is determined by invoking
the partitionSelectorClass, if present, or the partitionSelectorExpression %
partitionCount, where partitionCount is application count in the case of RabbitMQ, and the
underlying partition count of the topic in the case of Kafka.
The http app is expected to send the data in JSON and the filter app receives the JSON data and
processes it as a Spring Tuple. In order to do so, we use the inputType property on the filter app
to convert the data into the expected Spring Tuple format. The transform application processes the
Tuple data and sends the processed data to the downstream log application.
Depending on how applications are chained, the content type conversion can be specified either as
via the --outputType in the upstream app or as an --inputType in the downstream app. For
instance, in the above stream, instead of specifying the --inputType on the 'transform' application to
convert, the option --outputType=application/x-spring-tuple can also be specified on the
'http' application.
For the complete list of message conversion and message converters, please refer to Spring Cloud
Stream documentation.
Application properties that are defined during deployment override the same properties defined during
the stream creation.
For example, the following stream has application properties defined during stream creation:
dataflow:> stream create --definition "time --fixed-delay=5 | log --level=WARN" --name ticktock
To override these application properties, one can specify the new property values during deployment:
If the stream was deployed, it will be undeployed before the stream definition is deleted.
To create a stream using an http source, but still using the same log sink, we would change the
original command above to
Note that we don’t see any other output this time until we actually post some data (using a shell
command). In order to see the randomly assigned port on which the http source is listening, execute:
You should see that the corresponding http source has a url property containing the host and port
information on which it is listening. You are now ready to post to that url, e.g.:
and the stream will then funnel the data from the http source to the output log implemented by the log sink
Of course, we could also change the sink implementation. You could pipe the output to a file (file), to
hadoop (hdfs) or to any of the other sink apps which are available. You can also define your own apps.
dataflow:>http post --target http://localhost:9900 --data "How much wood would a woodchuck chuck if a
woodchuck could chuck wood"
> POST (text/plain;Charset=UTF-8) http://localhost:9900 How much wood would a woodchuck chuck if a
woodchuck could chuck wood
> 202 ACCEPTED
This shows that payload splits that contain the same word are routed to the same application instance.
To create a stream that acts as a 'tap' on another stream requires to specify the source destination
name for the tap stream. The syntax for source destination name is:
`:<streamName>.<label/appName>`
To create a tap at the output of http in the stream above, the source destination name is
mainstream.http To create a tap at the output of the first transform app in the stream above, the
source destination name is mainstream.step1
Note the colon (:) prefix before the destination names. The colon allows the parser to recognize this as
a destination name instead of an app name.
The following stream has the destination name at the source position:
This stream receives messages from the destination myDestination located at the broker and
connects it to the log app.
The following stream has the destination name at the sink position:
This stream sends the messages from the http app to the destination myDestination located at
the broker.
From the above streams, notice that the http and log apps are interacting with each other via the
broker (through the destination myDestination) rather than having a pipe directly between http and
log within a single stream.
It is also possible to connect two different destinations (source and sink positions) at the broker in
a stream.
In the above stream, both the destinations (destination1 and destination2) are located in the
broker. The messages flow from the source destination to the sink destination via a bridge app that
connects them.
First, named destinations may be used as a way to combine the output from multiple streams or for
multiple consumers to share the output from a single stream. This can be done using the DSL syntax
http > :mydestination or :mydestination > log.
Second, you may need to determine the output channel of a stream based on some information that is
only known at runtime. In that case, a router may be used in the sink position of a stream definition. For
more information, refer to the Router Sink starter’s README.
For example, all the launched applications can be configured to use a specific Kafka broker by launching
the configuration server with the following options:
--
spring.cloud.dataflow.applicationProperties.stream.spring.cloud.stream.kafka.binder.brokers=192.168.1.100:9092
--
spring.cloud.dataflow.applicationProperties.stream.spring.cloud.stream.kafka.binder.zkNodes=192.168.1.100:2181
Note
Properties configured using this mechanism have lower precedence than stream deployment
properties. They will be overridden if a property with the same key is specified at stream
deployment time (e.g. app.http.spring.cloud.stream.kafka.binder.brokers will
override the common property).
and in this stream, each application connects to messaging middleware in the following way:
Here, rabbit1 and kafka1 are the binder names given in the spring cloud stream application
properties. Based on this setup, the applications will have the following binder(s) in their classpath with
the appropriate configuration:
The spring-cloud-stream binder configuration properties can be set within the applications themselves.
If not, they can be passed via deployment properties when the stream is deployed.
For example,
One can override any of the binder configuration properties by specifying them via deployment
properties.
If you’re just starting out with Spring Cloud Data Flow, you should probably read the Getting Started
guide before diving into this section.
Spring Cloud Data Flow Reference Guide
3. Launch a Task
4. Task Execution
1. Create a new project via Spring Initializer via either the website or your IDE making sure to select
the following starters:
2. Within your new project, create a new class that will serve as your main class:
@EnableTask
@SpringBootApplication
public class MyTask {
3. With this, you’ll need one or more CommandLineRunner or ApplicationRunner within your
application. You can either implement your own or use the ones provided by Spring Boot (there is
one for running batch jobs for example).
4. Packaging your application up via Spring Boot into an über jar is done via the standard Boot
conventions.
When providing a URI with the maven scheme, the format should conform to the following:
maven://<groupId>:<artifactId>[:<extension>[:<classifier>]]:<version>
If you would like to register multiple apps at one time, you can store them in a properties file where
the keys are formatted as <type>.<name> and the values are the URIs. For example, this would be
a valid properties file:
task.foo=file:///tmp/foo.jar
task.bar=file:///tmp/bar.jar
Then use the app import command and provide the location of the properties file via --uri:
For convenience, we have the static files with application-URIs (for both maven and docker) available
for all the out-of-the-box Task app-starters. You can point to this file and import all the application-URIs
in bulk. Otherwise, as explained in previous paragraphs, you can register them individually or have your
own custom property file with only the required application-URIs in it. It is recommended, however, to
have a "focused" list of desired application-URIs in a custom property file.
For example, if you would like to register all out-of-the-box task applications in bulk, you can with the
following command.
You can also pass the --local option (which is TRUE by default) to indicate whether the properties
file location should be resolved within the shell process itself. If the location should be resolved from the
Data Flow Server process, specify --local false.
When using either app register or app import, if a task app is already registered with the provided
name, it will not be overridden by default. If you would like to override the pre-existing task app, then
include the --force option.
Note
In some cases the Resource is resolved on the server side, whereas in others the URI will be
passed to a runtime container instance where it is resolved. Consult the specific documentation
of each Data Flow Server for more detail.
create a task definition using the shell, use the task create command to create the task definition.
For example:
A listing of the current task definitions can be obtained via the restful API or the shell. To get the task
definition list using the shell, use the task list command.
When a task is launched, any properties that need to be passed as the command line arguments to the
task application can be set when launching the task as follows:
Additional properties meant for a TaskLauncher itself can be passed in using a --properties option.
Format of this option is a comma delimited string of properties prefixed with app.<task definition
name>.<property>. Properties are passed to TaskLauncher as application properties and it is up
to an implementation to choose how those are passed into an actual task application. If the property is
prefixed with deployer instead of app it is passed to TaskLauncher as a deployment property and
its meaning may be TaskLauncher implementation specific.
• Task Name
• Start Time
• End Time
• Exit Code
• Exit Message
• Parameters
A user can check the status of their task executions via the restful API or by the shell. To display the
latest task executions via the shell use the task execution list command.
To get a list of task executions for just one task definition, add --name and the task definition name, for
example task execution list --name foo. To retrieve full details for a task execution use the
task display command with the id of the task execution, for example task display --id 549.
The task execution information for previously launched tasks for the definition will remain in the task
repository.
Note: This will not stop any currently executing tasks for this definition, instead it just removes the task
definition from the database.
Local
2. In the dependencies section add the dependency for the database driver required. In the sample
below postgresql has been chosen.
<dependencies>
...
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
</dependency>
...
</dependencies>
4. Build the application as described here: Building Spring Cloud Data Flow
When launching a task application be sure that the database driver that is being used by Spring Cloud
Data Flow is also a dependency on the task application. For example if your Spring Cloud Data Flow is
set to use Postgresql, be sure that the task application also has Postgresql as a dependency.
Note
When executing tasks externally (i.e. command line) and you wish for Spring Cloud Data Flow
to show the TaskExecutions in its UI, be sure that common datasource settings are shared
among the both. By default Spring Cloud Task will use a local H2 instance and the execution
will not be recorded to the database used by Spring Cloud Data Flow.
36.2 Datasource
To configure the datasource Add the following properties to the dataflow-server.yml or via environment
variables:
a. spring.datasource.url
b. spring.datasource.username
c. spring.datasource.password
d. spring.datasource.driver-class-name
• Environment variables:
export spring_datasource_url=jdbc:postgresql://localhost:5432/mydb
export spring_datasource_username=myuser
export spring_datasource_password=mypass
export spring_datasource_driver-class-name="org.postgresql.Driver"
• dataflow-server.yml
spring:
datasource:
url: jdbc:postgresql://localhost:5432/mydb
username: myuser
password: mypass
driver-class-name:org.postgresql.Driver
You can control the destination name for those events by specifying explicit names when launching the
task such as:
The default Task/Batch event and destination names on the broker are enumerated below:
Event Destination
Note
The task-launcher-local can be added to the available sinks by executing the app register
command as follows:
38.1 TriggerTask
One way to launch a task using the task-launcher is to use the triggertask source. The
triggertask source will emit a message with a TaskLaunchRequest object containing the required
launch information. An example of this would be to launch the timestamp task once every 5 seconds,
the stream to implement this would look like:
38.2 Translator
Another option to start a task using the task-launcher would be to create a stream using a your own
translator (as a processor) to translate a message payload to a TaskLaunchRequest. For example:
39. Introduction
Spring Cloud Data Flow provides a browser-based GUI and it currently includes 6 tabs:
• Apps Lists all available applications and provides the control to register/unregister them
• Runtime Provides the Data Flow cluster view with the list of all running applications
Upon starting Spring Cloud Data Flow, the Dashboard is available at:
http://<host>:<port>/dashboard
40. Apps
The Apps section of the Dashboard lists all the available applications and provides the control to register/
unregister them (if applicable). It is possible to import a number of applications at once using the Bulk
Import Applications action.
<type>.<name> = <coordinates>
For example:
task.timestamp=maven://org.springframework.cloud.task.app:timestamp-
task:1.0.0.BUILD-SNAPSHOT
processor.transform=maven://org.springframework.cloud.stream.app:transform-
processor-rabbit:1.0.3.BUILD-SNAPSHOT
At the top of the bulk import page an Uri can be specified that points to a properties file stored
elsewhere, it should contain properties formatted as above. Alternatively, using the textbox labeled Apps
as Properties it is possible to directly list each property string. Finally, if the properties are stored in a
local file the Select Properties File option will open a local file browser to select the file. After setting
your definitions via one of these routes, click Import.
At the bottom of the page there are quick links to the property files for common groups of stream apps
and task apps. If those meet your needs, simply select your appropriate variant (rabbit, kafka, docker,
etc) and click the Import action on those lines to immediately import all those applications.
41. Runtime
The Runtime section of the Dashboard application shows the Spring Cloud Data Flow cluster view with
the list of all running applications. For each runtime app the state of the deployment and the number
of deployed instances is shown. A list of the used deployment properties is available by clicking on the
app id.
42. Streams
The Streams section of the Dashboard provides the Definitions tab that provides a listing of Stream
definitions. There you have the option to deploy or undeploy those stream definitions. Additionally
you can remove the definition by clicking on destroy. Each row includes an arrow on the left, which
can be clicked to see a visual representation of the definition. Hovering over the boxes in the visual
representation will show more details about the apps including any options passed to them. In this
screenshot the timer stream has been expanded to show the visual representation:
If the details button is clicked the view will change to show a visual representation of that stream and
also any related streams. In the above example, if clicking details for the timer stream, the view will
change to the one shown below which clearly shows the relationship between the three streams (two
of them are tapping into the timer stream).
• Create, manage, and visualize stream pipelines using DSL, a graphical canvas, or both
• Use auto-adjustment and grid-layout capabilities in the GUI for simpler and interactive organization
of pipelines
Watch this screencast that highlights some of the "Flo for Spring Cloud Data Flow" capabilities. Spring
Flo wiki includes more detailed content on core Flo capabilities.
44. Tasks
The Tasks section of the Dashboard currently has three tabs:
• Apps
• Definitions
• Executions
44.1 Apps
Apps encapsulate a unit of work into a reusable component. Within the Data Flow runtime environment
Apps allow users to create definitions for Streams as well as Tasks. Consequently, the Apps tab within
the Tasks section allows users to create Task definitions.
Note: You will also use this tab to create Batch Jobs.
On this screen you can create a new Task Definition. As a minimum you must provide a name for
the new definition. You will also have the option to specify various properties that are used during the
deployment of the app.
44.2 Definitions
This page lists the Data Flow Task definitions and provides actions to launch or destroy those tasks.
It also provides a shortcut operation to define one or more tasks using simple textual input, indicated
by the bulk define tasks button.
It includes a textbox where one or more definitions can be entered and then various actions performed
on those definitions. The required input text format for task definitions is very basic, each line should
be of the form:
For example:
After entering any data a validator will run asynchronously to verify both the syntax and that the
application name entered is a valid application and it supports the options specified. If validation fails
the editor will show the errors with more information via tooltips.
To make it easier to enter definitions into the text area, content assist is supported. Pressing Ctrl+Space
will invoke content assist to suggest simple task names (based on the line on which it is invoked), task
applications and task application options. Press ESCape to close the content assist window without
taking a selection.
If the validator should not verify the applications or the options (for example if specifying non-whitelisted
options to the applications) then turn off that part of validation by toggling the checkbox off on the Verify
Apps button - the validator will then only perform syntax checking. When correctly validated, the create
button will be clickable and on pressing it the UI will proceed to create each task definition. If there are
any errors during creation then after creation finishes the editor will show any lines of input, as it cannot
be used in task definitions. These can then be fixed up and creation repeated. There is an import file
button to open a file browser on the local file system if the definitions are in a file and it is easier to
import than copy/paste.
Launching Tasks
Once the task definition is created, they can be launched through the Dashboard as well. Navigate to
the Definitions tab. Select the Task you want to launch by pressing Launch.
On the following screen, you can define one or more Task parameters by entering:
• Parameter Key
• Parameter Value
44.3 Executions
45. Jobs
The Jobs section of the Dashboard allows you to inspect Batch Jobs. The main section of the screen
provides a list of Job Executions. Batch Jobs are Tasks that were executing one or more Batch Job.
As such each Job Execution has a back reference to the Task Execution Id (Task Id).
In case of a failed job, you can also restart the task. When dealing with long-running Batch Jobs, you
can also request to stop it.
The list of Job Executions also shows the state of the underlying Job Definition. Thus, if the underlying
definition has been deleted, deleted will be shown.
The Job Execution Details screen also contains a list of the executed steps. You can further drill into
the Step Execution Details by clicking onto the magnifying glass.
On the top of the page, you will see progress indicator the respective step, with the option to refresh the
indicator. Furthermore, a link is provided to view the step execution history.
The Step Execution details screen provides a complete list of all Step Execution Context key/value pairs.
Important
In case of exceptions, the Exit Description field will contain additional error information. Please
be aware, though, that this field can only have a maximum of 2500 characters. Therefore, in
case of long exception stacktraces, trimming of error messages may occur. In that case, please
refer to the server log files for further details.
On this screen, you can see a progress bar indicator in regards to the execution of the current step.
Under the Step Execution History, you can also view various metrics associated with the selected
step such as duration, read counts, write counts etc.
46. Analytics
The Analytics section of the Dashboard provided data visualization capabilities for the various analytics
applications available in Spring Cloud Data Flow:
• Counters
• Field-Value Counters
• Aggregate Counters
For example, if you have created the springtweets stream and the corresponding counter in the
Counter chapter, you can now easily create the corresponding graph from within the Dashboard tab:
Using the icons to the right, you can add additional charts to the Dashboard, re-arange the order of
created dashboards or remove data visualizations.
If you are having a specific problem that we don’t cover here, you might want to check out
stackoverflow.com to see if someone has already provided an answer; this is also a great place to ask
new questions (please use the spring-cloud-dataflow tag).
We’re also more than happy to extend this section; If you want to add a ‘how-to’ you can send us a
pull request.
Spring Cloud Data Flow Reference Guide
The remote maven repositories need to be configured explicitly if the apps are resolved using maven
repository except for local Data Flow server. The other Data Flow server implementations (that use
maven resources for app artifacts resolution) have no default value for remote repositories. The local
server has repo.spring.io/libs-snapshot as the default remote repository.
Formatted JSON:
SPRING_APPLICATION_JSON='{
"maven": {
"local-repository": "local",
"remote-repositories": {
"repo1": {
"url": "https://repo1",
"auth": {
"username": "repo1user",
"password": "repo1pass"
}
},
"repo2": {
"url": "https://repo2"
}
},
"proxy": {
"host": "proxyhost",
"port": 9018,
"auth": {
"username": "proxyuser",
"password": "proxypass"
}
}
}
}'
Note
Depending on Spring Cloud Data Flow server implementation, you may have
to pass the environment properties using the platform specific environment-setting
48. Logging
Spring Cloud Data Flow is built upon several Spring projects, but ultimately the dataflow-server is a
Spring Boot app, so the logging techniques that apply to any Spring Boot application are applicable
here as well.
While troubleshooting, following are the two primary areas where enabling the DEBUG logs could be
useful.
1. For instance, if you’d like to enable DEBUG logs for the local-deployer, you’d be starting the server
with following.
2. For instance, if you’d like to enable DEBUG logs for the cloudfoundry-deployer, you’d be setting the
following environment variable and upon restaging the dataflow-server, we will see more logs around
request, response and the elaborate stack traces (upon failures). The cloudfoundry-deployer uses
cf-java-client, so we will have to enable DEBUG logs for this library.
3. If there’s a need to review Reactor logs, which is used by the cf-java-client, then the following
would be helpful.
Note
For instance, if you’d have to troubleshoot the header and payload specifics that are being passed
around source, processor and sink channels, you’d be deploying the stream with the following options.
These properties can also be specified via deployment properties when deploying the stream.
49. Overview
Spring Cloud Data Flow provides a REST API allowing you to access all aspects of the server. In fact
the Spring Cloud Data Flow Shell is a first-class consumer of that API.
Tip
If you plan on using the REST API using Java, please also consider using the provided Java
client (DataflowTemplate) that uses the REST API internally.
Verb Usage
400 Bad Request The request was malformed. The response body
will include an error providing further information
49.3 Headers
Every response has the following header(s):
Name Description
49.4 Errors
49.5 Hypermedia
Spring Cloud Data Flow uses hypermedia and resources include links to other resources in their
responses. Responses are in Hypertext Application from resource to resource Language (HAL) format.
Links can be found beneath the _links key. Users of the API should not create URIs themselves,
instead they should use the above-described links to navigate.
50. Resources
50.1 Index
The index provides the entry point into Spring Cloud Data Flow’s REST API.
Request structure
GET / HTTP/1.1
Host: localhost:8080
Example request
$ curl 'http://localhost:8080/' -i
Response structure
Example response
HTTP/1.1 200 OK
Content-Type: application/hal+json;charset=UTF-8
Content-Length: 3880
{
"_links" : {
"dashboard" : {
"href" : "http://localhost:8080/dashboard"
},
"streams/definitions" : {
"href" : "http://localhost:8080/streams/definitions"
},
"streams/definitions/definition" : {
"href" : "http://localhost:8080/streams/definitions/{name}",
"templated" : true
},
"streams/deployments" : {
"href" : "http://localhost:8080/streams/deployments"
},
"streams/deployments/deployment" : {
"href" : "http://localhost:8080/streams/deployments/{name}",
"templated" : true
},
"runtime/apps" : {
"href" : "http://localhost:8080/runtime/apps"
},
"runtime/apps/app" : {
"href" : "http://localhost:8080/runtime/apps/{appId}",
"templated" : true
},
"runtime/apps/instances" : {
"href" : "http://localhost:8080/runtime/apps/interface
%20org.springframework.web.util.UriComponents%24UriTemplateVariables/instances"
},
"tasks/definitions" : {
"href" : "http://localhost:8080/tasks/definitions"
},
"tasks/definitions/definition" : {
"href" : "http://localhost:8080/tasks/definitions/{name}",
"templated" : true
},
"tasks/composed-definitions/compose" : {
"href" : "http://localhost:8080/tasks/composed-definitions"
},
"tasks/executions" : {
"href" : "http://localhost:8080/tasks/executions"
},
"tasks/executions/name" : {
"href" : "http://localhost:8080/tasks/executions{?name}",
"templated" : true
},
"tasks/executions/execution" : {
"href" : "http://localhost:8080/tasks/executions/{id}",
"templated" : true
},
"jobs/executions" : {
"href" : "http://localhost:8080/jobs/executions"
},
"jobs/executions/name" : {
"href" : "http://localhost:8080/jobs/executions{?name}",
"templated" : true
},
"jobs/executions/execution" : {
"href" : "http://localhost:8080/jobs/executions/{id}",
"templated" : true
},
"jobs/executions/execution/steps" : {
"href" : "http://localhost:8080/jobs/executions/{jobExecutionId}/steps",
"templated" : true
},
"jobs/executions/execution/steps/step" : {
"href" : "http://localhost:8080/jobs/executions/{jobExecutionId}/steps/{stepId}",
"templated" : true
},
"jobs/executions/execution/steps/step/progress" : {
"href" : "http://localhost:8080/jobs/executions/{jobExecutionId}/steps/{stepId}/progress",
"templated" : true
},
"jobs/instances/name" : {
"href" : "http://localhost:8080/jobs/instances{?name}",
"templated" : true
},
"jobs/instances/instance" : {
"href" : "http://localhost:8080/jobs/instances/{id}",
"templated" : true
},
"counters" : {
"href" : "http://localhost:8080/metrics/counters"
},
"counters/counter" : {
"href" : "http://localhost:8080/metrics/counters/{name}",
"templated" : true
},
"field-value-counters" : {
"href" : "http://localhost:8080/metrics/field-value-counters"
},
"field-value-counters/counter" : {
"href" : "http://localhost:8080/metrics/field-value-counters/{name}",
"templated" : true
},
"aggregate-counters" : {
"href" : "http://localhost:8080/metrics/aggregate-counters"
},
"aggregate-counters/counter" : {
"href" : "http://localhost:8080/metrics/aggregate-counters/{name}",
"templated" : true
},
"apps" : {
"href" : "http://localhost:8080/apps"
},
"about" : {
"href" : "http://localhost:8080/about"
},
"completions/stream" : {
"href" : "http://localhost:8080/completions/stream{?start,detailLevel}",
"templated" : true
},
"completions/task" : {
"href" : "http://localhost:8080/completions/task{?start,detailLevel}",
"templated" : true
}
},
"api.revision" : 12
}
HTTP/1.1 200 OK
Content-Type: application/hal+json;charset=UTF-8
Content-Length: 3880
{
"_links" : {
"dashboard" : {
"href" : "http://localhost:8080/dashboard"
},
"streams/definitions" : {
"href" : "http://localhost:8080/streams/definitions"
},
"streams/definitions/definition" : {
"href" : "http://localhost:8080/streams/definitions/{name}",
"templated" : true
},
"streams/deployments" : {
"href" : "http://localhost:8080/streams/deployments"
},
"streams/deployments/deployment" : {
"href" : "http://localhost:8080/streams/deployments/{name}",
"templated" : true
},
"runtime/apps" : {
"href" : "http://localhost:8080/runtime/apps"
},
"runtime/apps/app" : {
"href" : "http://localhost:8080/runtime/apps/{appId}",
"templated" : true
},
"runtime/apps/instances" : {
"href" : "http://localhost:8080/runtime/apps/interface
%20org.springframework.web.util.UriComponents%24UriTemplateVariables/instances"
},
"tasks/definitions" : {
"href" : "http://localhost:8080/tasks/definitions"
},
"tasks/definitions/definition" : {
"href" : "http://localhost:8080/tasks/definitions/{name}",
"templated" : true
},
"tasks/composed-definitions/compose" : {
"href" : "http://localhost:8080/tasks/composed-definitions"
},
"tasks/executions" : {
"href" : "http://localhost:8080/tasks/executions"
},
"tasks/executions/name" : {
"href" : "http://localhost:8080/tasks/executions{?name}",
"templated" : true
},
"tasks/executions/execution" : {
"href" : "http://localhost:8080/tasks/executions/{id}",
"templated" : true
},
"jobs/executions" : {
"href" : "http://localhost:8080/jobs/executions"
},
"jobs/executions/name" : {
"href" : "http://localhost:8080/jobs/executions{?name}",
"templated" : true
},
"jobs/executions/execution" : {
"href" : "http://localhost:8080/jobs/executions/{id}",
"templated" : true
},
"jobs/executions/execution/steps" : {
"href" : "http://localhost:8080/jobs/executions/{jobExecutionId}/steps",
"templated" : true
},
"jobs/executions/execution/steps/step" : {
"href" : "http://localhost:8080/jobs/executions/{jobExecutionId}/steps/{stepId}",
"templated" : true
},
"jobs/executions/execution/steps/step/progress" : {
"href" : "http://localhost:8080/jobs/executions/{jobExecutionId}/steps/{stepId}/progress",
"templated" : true
},
"jobs/instances/name" : {
"href" : "http://localhost:8080/jobs/instances{?name}",
"templated" : true
},
"jobs/instances/instance" : {
"href" : "http://localhost:8080/jobs/instances/{id}",
"templated" : true
},
"counters" : {
"href" : "http://localhost:8080/metrics/counters"
},
"counters/counter" : {
"href" : "http://localhost:8080/metrics/counters/{name}",
"templated" : true
},
"field-value-counters" : {
"href" : "http://localhost:8080/metrics/field-value-counters"
},
"field-value-counters/counter" : {
"href" : "http://localhost:8080/metrics/field-value-counters/{name}",
"templated" : true
},
"aggregate-counters" : {
"href" : "http://localhost:8080/metrics/aggregate-counters"
},
"aggregate-counters/counter" : {
"href" : "http://localhost:8080/metrics/aggregate-counters/{name}",
"templated" : true
},
"apps" : {
"href" : "http://localhost:8080/apps"
},
"about" : {
"href" : "http://localhost:8080/about"
},
"completions/stream" : {
"href" : "http://localhost:8080/completions/stream{?start,detailLevel}",
"templated" : true
},
"completions/task" : {
"href" : "http://localhost:8080/completions/task{?start,detailLevel}",
"templated" : true
}
},
"api.revision" : 12
}
Links
The main element of the index are the links as they allow you to traverse the API and execute the
desired functionality:
Relation Description
Relation Description
• Security information
Request structure
GET /about HTTP/1.1
Accept: application/json
Host: localhost:8080
Request parameters
Unresolved directive in api-guide.adoc - include::/opt/bamboo-home/xml-data/build-dir/SCD-
BMASTER-JOB1/spring-cloud-dataflow-docs/target/generated-snippets/about-documentation/get-
meta-information/request-parameters.adoc[]
Example request
$ curl 'http://localhost:8080/about' -i -H 'Accept: application/json'
Response structure
HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
Content-Length: 1884
{
"featureInfo" : {
"analyticsEnabled" : true,
"streamsEnabled" : true,
"tasksEnabled" : true
},
"versionInfo" : {
"implementation" : {
"name" : "spring-cloud-starter-dataflow-server-local",
"version" : "1.2.0.M3"
},
"core" : {
"name" : "Spring Cloud Data Flow Core",
"version" : "1.2.0.M3"
},
"dashboard" : {
"name" : "Spring Cloud Dataflow UI",
"version" : "1.2.0.M2"
},
"commitId" : null,
"shortCommitId" : null,
"commitTime" : null,
"branch" : null
},
"securityInfo" : {
"authenticationEnabled" : false,
"authorizationEnabled" : true,
"formLogin" : false,
"authenticated" : false,
"username" : null,
"roles" : [ ]
},
"runtimeEnvironment" : {
"appDeployer" : {
"deployerImplementationVersion" : "1.2.0.M3",
"deployerName" : "LocalAppDeployer",
"deployerSpiVersion" : "1.2.0.M3",
"javaVersion" : "1.8.0_121",
"platformApiVersion" : "Linux 4.4.0-66-generic",
"platformClientVersion" : "4.4.0-66-generic",
"platformHostVersion" : "4.4.0-66-generic",
"platformSpecificInfo" : { },
"platformType" : "Local",
"springBootVersion" : "1.5.2.RELEASE",
"springVersion" : "4.3.6.RELEASE"
},
"taskLauncher" : {
"deployerImplementationVersion" : "1.2.0.M3",
"deployerName" : "LocalTaskLauncher",
"deployerSpiVersion" : "1.2.0.M3",
"javaVersion" : "1.8.0_121",
"platformApiVersion" : "Linux 4.4.0-66-generic",
"platformClientVersion" : "4.4.0-66-generic",
"platformHostVersion" : "4.4.0-66-generic",
"platformSpecificInfo" : { },
"platformType" : "Local",
"springBootVersion" : "1.5.2.RELEASE",
"springVersion" : "4.3.6.RELEASE"
}
},
"_links" : {
"self" : {
"href" : "http://localhost:8080/about"
}
}
}
Request structure
GET /apps?type=source HTTP/1.1
Accept: application/json
Host: localhost:8080
Request parameters
Parameter Description
Example request
$ curl 'http://localhost:8080/apps?type=source' -i -H 'Accept: application/json'
Response structure
HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
Content-Length: 185
{
"_links" : {
"self" : {
"href" : "http://localhost:8080/apps"
}
},
"page" : {
"size" : 0,
"totalElements" : 0,
"totalPages" : 1,
"number" : 0
}
}
51. Overview
The central entrypoint is the DataFlowTemplate class in package
org.springframework.cloud.dataflow.rest.client.
This class implements the interface DataFlowOperations and delegates to sub-templates that
provide the specific functionality for each feature-set:
Interface Description
When the DataFlowTemplate is being initialized, the sub-templates will be discovered via the REST
1
relations, which are provided by HATEOAS.
Important
If a resource cannot be resolved, the respective sub-template will result in being NULL. A
common cause is that Spring Cloud Data Flow offers for specific sets of features to be enabled/
disabled when launching. For more information see Chapter 15, Feature Toggles.
1
HATEOAS stands for Hypermedia as the Engine of Application State
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dataflow-rest-client</artifactId>
<version>1.2.0.M3</version>
</dependency>
With that dependency you will get the DataFlowTemplate class as well as all needed dependencies
to make calls to a Spring Cloud Data Flow server.
When instantiating the DataFlowTemplate, you will also pass in a RestTemplate. Please be aware
that the needed RestTemplate requires some additional configuration to be valid in the context of
the DataFlowTemplate. When declaring a RestTemplate as a bean, the following configuration will
suffice:
@Bean
public static RestTemplate restTemplate() {
RestTemplate restTemplate = new RestTemplate();
restTemplate.setErrorHandler(new VndErrorResponseErrorHandler(restTemplate.getMessageConverters()));
for(HttpMessageConverter<?> converter : restTemplate.getMessageConverters()) {
if (converter instanceof MappingJackson2HttpMessageConverter) {
final MappingJackson2HttpMessageConverter jacksonConverter =
(MappingJackson2HttpMessageConverter) converter;
jacksonConverter.getObjectMapper()
.registerModule(new Jackson2HalModule())
.addMixIn(JobExecution.class, JobExecutionJacksonMixIn.class)
.addMixIn(JobParameters.class, JobParametersJacksonMixIn.class)
.addMixIn(JobParameter.class, JobParameterJacksonMixIn.class)
.addMixIn(JobInstance.class, JobInstanceJacksonMixIn.class)
.addMixIn(ExitStatus.class, ExitStatusJacksonMixIn.class)
.addMixIn(StepExecution.class, StepExecutionJacksonMixIn.class)
.addMixIn(ExecutionContext.class, ExecutionContextJacksonMixIn.class)
.addMixIn(StepExecutionHistory.class, StepExecutionHistoryJacksonMixIn.class);
}
}
return restTemplate;
}
❶ The URI points to the ROOT of your Spring Cloud Data Flow Server.
Depending on your requirements, you can now make calls to the server. For instance, if you like to get
a list of currently available applications you can execute:
System.out.println(String.format("Retrieved %s application(s)",
apps.getContent().size()));
Old New
XD-Container N/A
Modules Applications
Admin UI Dashboard
Custom Applications
• Spring XD’s stream and batch modules are refactored into Spring Cloud Stream and Spring Cloud
Task application-starters, respectively. These applications can be used as the reference while
refactoring Spring XD modules
• There are also some samples for Spring Cloud Stream and Spring Cloud Task applications for
reference
• If you’d like to create a brand new custom application, use the getting started guide for Spring Cloud
Stream and Spring Cloud Task applications and as well as review the development guide
• Alternatively, if you’d like to patch any of the out-of-the-box stream applications, you can follow the
procedure here
Application Registration
• Custom Stream/Task application requires being installed to a maven repository for Local, YARN, and
CF implementations or as docker images, when deploying to Kubernetes and Mesos. Other than
maven and docker resolution, you can also resolve application artifacts from http, file, or as hdfs
coordinates
• Unlike Spring XD, you do not have to upload the application bits while registering custom applications
anymore; instead, you’re expected to register the application coordinates that are hosted in the maven
repository or by other means as discussed in the previous bullet
• By default, none of the out-of-the-box applications are preloaded already. It is intentionally designed
to provide the flexibility to register app(s), as you find appropriate for the given use-case requirement
• Depending on the binder choice, you can manually add the appropriate binder dependency to build
applications specific to that binder-type. Alternatively, you can follow the Spring Initialzr procedure to
create an application with binder embedded in it
Application Properties
• counter-sink:
• The peripheral redis is not required in Spring Cloud Data Flow. If you intend to use the counter-
sink, then redis becomes required, and you’re expected to have your own running redis cluster
• field-value-counter-sink:
• The peripheral redis is not required in Spring Cloud Data Flow. If you intend to use the field-
value-counter-sink, then redis becomes required, and you’re expected to have your own
running redis cluster
• aggregate-counter-sink:
• The peripheral redis is not required in Spring Cloud Data Flow. If you intend to use the
aggregate-counter-sink, then redis becomes required, and you’re expected to have your
own running redis cluster
Message Bus
Similar to Spring XD, there’s an abstraction available to extend the binder interface. By default, we take
the opinionated view of Apache Kafka and RabbitMQ as the production-ready binders and are available
as GA releases.
Binders
Selecting a binder is as simple as providing the right binder dependency in the classpath. If you’re to
choose Kafka as the binder, you’d register stream applications that are pre-built with Kafka binder in
it. If you were to create a custom application with Kafka binder, you’d add the following dependency
in the classpath.
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-stream-binder-kafka</artifactId>
<version>1.0.2.RELEASE</version>
</dependency>
• Spring Cloud Stream supports Apache Kafka, RabbitMQ and experimental Google PubSub and
Solace JMS. All binder implementations are maintained and managed in their individual repositories
• Every Stream/Task application can be built with a binder implementation of your choice. All the out-
of-the-box applications are pre-built for both Kafka and Rabbit and they’re readily available for use as
maven artifacts [Spring Cloud Stream / Spring Cloud Task or docker images [Spring Cloud Stream /
Spring Cloud Task Changing the binder requires selecting the right binder dependency. Alternatively,
you can download the pre-built application from this version of Spring Initializr with the desired “binder-
starter” dependency
Named Channels
Fundamentally, all the messaging channels are backed by pub/sub semantics. Unlike Spring XD, the
messaging channels are backed only by topics or topic-exchange and there’s no representation
of queues in the new architecture.
• ${xd.module.index} is not supported anymore; instead, you can directly interact with named
destinations
Directed Graphs
If you’re building non-linear streams, you could take advantage of named destinations to build directed
graphs.
• Spring Batch jobs from Spring XD are being refactored to Spring Boot applications a.k.a link: Spring
Cloud Task applications
• Unlike Spring XD, these “Tasks” don’t require explicit deployment; instead, a task is ready to be
launched directly once the definition is declared
A.6 REST-API
/modules /apps
/runtime/modules /runtime/apps
/runtime/modules/{moduleId} /runtime/apps/{appId}
/jobs/definitions /task/definitions
/jobs/deployments /task/deployments
A.7 UI / Flo
The Admin-UI is now renamed as Dashboard. The URI for accessing the Dashboard is changed from
localhost:9393/admin-ui to localhost:9393/dashboard
• (New) Apps: Lists all the registered applications that are available for use. This view includes
informational details such as the URI and the properties supported by each application. You can also
register/unregister applications from this view
• Runtime: Container changes to Runtime. The notion of xd-container is gone, replaced by out-
of-the-box applications running as autonomous Spring Boot applications. The Runtime tab displays
the applications running in the runtime platforms (implementations: cloud foundry, apache yarn,
apache mesos, or kubernetes). You can click on each application to review relevant details about the
application such as where it is running with, and what resources etc.
• Spring Flo is now an OSS product. Flo for Spring Cloud Data Flow’s “Create Stream”, the designer-
tab comes pre-built in the Dashboard
• (New) Tasks:
• The sub-tab “Definitions” lists all the Task definitions, including Spring Batch jobs that are
orchestrated as Tasks
• The sub-tab “Executions” lists all the Task execution details similar to Spring XD’s Job executions
ZooKeeper
ZooKeeper is not used in the new architecture.
RDBMS
Spring Cloud Data Flow uses an RDBMS instead of Redis for stream/task definitions, application
registration, and for job repositories.The default configuration uses an embedded H2 instance, but
Oracle, DB2, SqlServer, MySQL/MariaDB, PostgreSQL, H2, and HSQLDB databases are supported.
To use Oracle, DB2 and SqlServer you will need to create your own Data Flow Server using Spring
Initializr and add the appropriate JDBC driver dependency.
Redis
Running a Redis cluster is only required for analytics functionality. Specifically, when the counter-
sink, field-value-counter-sink, or aggregate-counter-sink applications are used, it is
expected to also have a running instance of Redis cluster.
Cluster Topology
Spring XD’s xd-admin and xd-container server components are replaced by stream and task
applications themselves running as autonomous Spring Boot applications. The applications run natively
on various platforms including Cloud Foundry, Apache YARN, Apache Mesos, or Kubernetes. You can
develop, test, deploy, scale +/-, and interact with (Spring Boot) applications individually, and they can
evolve in isolation.
A.10 Distribution
Spring Cloud Data Flow is a Spring Boot application. Depending on the platform of your choice, you
can download the respective release uber-jar and deploy/push it to the runtime platform (cloud foundry,
apache yarn, kubernetes, or apache mesos). For example, if you’re running Spring Cloud Data Flow
on Cloud Foundry, you’d download the Cloud Foundry server implementation and do a cf push as
explained in the reference guide.
• Cloudera - cdh5
• Leverage Apache Ambari plugin to provision Spring Cloud Data Flow as a service
Use Case #1
Start xd-shell server from the CLI Start dataflow-shell server from the CLI
# xd-shell
Review ticktock results in the xd- Review ticktock results by tailing the
singlenode server console ticktock.log/stdout_log application logs
Use Case #2
(It is assumed both XD and SCDF distributions are already downloaded)
Start xd-shell server from the CLI Start dataflow-shell server from the CLI
Create a stream with custom module Create a stream with custom application
Review results in the xd-singlenode server Review results by tailing the testupper.log/
console stdout_log application logs
Use Case #3
(It is assumed both XD and SCDF distributions are already downloaded)
Start xd-shell server from the CLI Start dataflow-shell server from the CLI
Create a job with custom batch-job module Create a task with custom batch-job application
Deploy job NA
Review results in the xd-singlenode server Review results by tailing the batchtest/
console as well as Jobs tab in UI (executions stdout_log application logs as well as Task
sub-tab should include all step details) tab in UI (executions sub-tab should include all
step details)
Appendix B. Building
To build the source you will need to install JDK 1.8.
The build uses the Maven wrapper so you don’t have to install a specific version of Maven. To enable
the tests for Redis you should run the server before bulding. See below for more information on how
to run Redis.
You can also add '-DskipTests' if you like, to avoid running the tests.
Note
You can also install Maven (>=3.3.3) yourself and run the mvn command in place of ./mvnw in
the examples below. If you do that you also might need to add -P spring if your local Maven
settings do not contain repository declarations for spring pre-release artifacts.
Note
Be aware that you might need to increase the amount of memory available to Maven by setting
a MAVEN_OPTS environment variable with a value like -Xmx512m -XX:MaxPermSize=128m.
We try to cover this in the .mvn configuration, so if you find you have to do it to make a build
succeed, please raise a ticket to get the settings added to source control.
The projects that require middleware generally include a docker-compose.yml, so consider using
Docker Compose to run the middeware servers in Docker containers. See the README in the scripts
demo repository for specific instructions about the common cases of mongo, rabbit and redis.
B.1 Documentation
There is a "full" profile that will generate documentation. You can build just the documentation by
executing
We recommend the m2eclipe eclipse plugin when working with eclipse. If you don’t already have
m2eclipse installed it is available from the "eclipse marketplace".
Unfortunately m2e does not yet support Maven 3.3, so once the projects are imported into Eclipse you
will also need to tell m2eclipse to use the .settings.xml file for the projects. If you do not do this
you may see many different errors related to the POMs in the projects. Open your Eclipse preferences,
expand the Maven preferences, and select User Settings. In the User Settings field click Browse and
navigate to the Spring Cloud project you imported selecting the .settings.xml file in that project.
Click Apply and then OK to save the preference changes.
Note
Alternatively you can copy the repository settings from .settings.xml into your own ~/.m2/
settings.xml.
If you prefer not to use m2eclipse you can generate eclipse project metadata using the following
command:
$ ./mvnw eclipse:eclipse
The generated eclipse projects can be imported by selecting import existing projects from the
file menu.
Appendix C. Contributing
Spring Cloud is released under the non-restrictive Apache 2.0 license, and follows a very standard
Github development process, using Github tracker for issues and merging pull requests into master. If
you want to contribute even something trivial please do not hesitate, but follow the guidelines below.
• Use the Spring Framework code format conventions. If you use Eclipse you can import formatter
settings using the eclipse-code-formatter.xml file from the Spring Cloud Build project. If using
IntelliJ, you can use the Eclipse Code Formatter Plugin to import the same file.
• Make sure all new .java files to have a simple Javadoc class comment with at least an @author
tag identifying you, and preferably at least a paragraph on what the class is for.
• Add the ASF license header comment to all new .java files (copy from existing files in the project)
• Add yourself as an @author to the .java files that you modify substantially (more than cosmetic
changes).
• Add some Javadocs and, if you change the namespace, some XSD doc elements.
• A few unit tests would help a lot as well — someone has to do it.
• If no-one else is using your branch, please rebase it against the current master (or other target branch
in the main project).
• When writing a commit message please follow these conventions, if you are fixing an existing issue
please add Fixes gh-XXXX at the end of the commit message (where XXXX is the issue number).