Setting up Spring Cloud Data Flow server

Let's use Spring Initializr (https://start.spring.io) to set up the application. Provide the details listed here and click on Generate Project:

  • Group: com.mastering.spring.cloud.data.flow
  • Artifact: local-data-flow-server
  • Dependencies: Local Data Flow Server

Listed here are some of the important dependencies from the pom.xml file:

    <dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-dataflow-server-
local</artifactId>
</dependency>

Update the SpringBootApplication file with the following code:

    @EnableDataFlowServer
@SpringBootApplication
public class LocalDataFlowServerApplication {
public static void main(String[] args) {
SpringApplication.run(LocalDataFlowServierApplication.class,
args);
}
}

The @EnableDataFlowServer annotation is used to activate a Spring Cloud Data Flow Server implementation.

Before you run the Local Data Flow Server, ensure that the message broker RabbitMQ is up and running.

The following is an important extract from the start up log when LocalDataFlowServerApplication is launched:

Tomcat initialized with port(s): 9393 (http)
Starting H2 Server with URL: jdbc:h2:tcp://localhost:19092/mem:dataflow
Adding dataflow schema classpath:schema-h2-common.sql for h2 database
Adding dataflow schema classpath:schema-h2-streams.sql for h2 database
Adding dataflow schema classpath:schema-h2-tasks.sql for h2 database
Adding dataflow schema classpath:schema-h2-deployment.sql for h2 database
Executed SQL script from class path resource [schema-h2-common.sql] in 37 ms.
Executed SQL script from class path resource [schema-h2-streams.sql] in 2 ms.
Executed SQL script from class path resource [schema-h2-tasks.sql] in 3 ms.
Executing SQL script from class path resource [schema-h2-deployment.sql]
Executed SQL script from class path resource [schema-h2-deployment.sql] in 3 ms.
Mapped "{[/runtime/apps/{appId}/instances]}" onto public org.springframework.hateoas.PagedResources
Mapped "{[/runtime/apps/{appId}/instances/{instanceId}]}" onto public
Mapped "{[/streams/definitions/{name}],methods=[DELETE]}" onto public void org.springframework.cloud.dataflow.server.controller.StreamDefinitionController.delete(java.lang.String)
Mapped "{[/streams/definitions],methods=[GET]}" onto public org.springframework.hateoas.PagedResources
Mapped "{[/streams/deployments/{name}],methods=[POST]}" onto public void org.springframework.cloud.dataflow.server.controller.StreamDeploymentController.deploy(java.lang.String,java.util.Map<java.lang.String, java.lang.String>)
Mapped "{[/runtime/apps]}" onto public org.springframework.hateoas.PagedResources<org.springframework.cloud.dataflow.rest.resource.AppStatusResource> org.springframework.cloud.dataflow.server.controller.RuntimeAppsController.list(org.springframework.data.domain.Pageable,org.springframework.data.web.PagedResourcesAssembler<org.springframework.cloud.deployer.spi.app.AppStatus>) throws java.util.concurrent.ExecutionException,java.lang.InterruptedException
Mapped "{[/tasks/executions],methods=[GET]}" onto public org.springframework.hateoas.PagedResources

A few important things to note are as follows:

  • The default port for Spring Cloud Data Flow server is 9393. This can be changed by specifying a different port as server.port in application.properties.
  • Spring Cloud Data Flow Server uses an internal schema to store all the configuration of applications, tasks, and streams. In this example, we have not configured any database. So, by default, the H2 in-memory database is used. Spring Cloud Data Flow Server supports a variety of databases, including MySQL and Oracle, to store the configuration.
  • Since H2 in-memory database is used, you can see that different schemas are set up during start up and also the different SQL scripts to set up data are executed.
  • Spring Cloud Data Flow Server exposes a number of APIs around its configuration, applications, tasks, and streams. We will discuss more about these APIs in a later section.

The following screenshot shows the launch screen of Spring Cloud Data Flow at http://localhost:9393/dashboard:

There are different tabs that can be used to view and modify applications, streams, and tasks. In the next step, we will use the command-line interface--the Data Flow Shell to set up applications and streams.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset