<p><strong>Background</strong></p>
<p>I have Spring Cloud Data Flow Server running in Kubernetes as a Pod. I am able to launch tasks from the <a href="https://docs.spring.io/spring-cloud-dataflow/docs/current/reference/htmlsingle/#dashboard" rel="nofollow noreferrer">SCDF server UI</a> dashboard. I am looking to develop a more complicated, real-world task- pipeline use-case.</p>
<p>Instead of using the SCDF UI dashboard, I want to launch a sequential list of tasks from a standard Java application. Consider the following task pipeline :</p>
<p><strong>Task 1 :</strong> Reads data from the database for the unique id received as task argument input and performs enrichments. The enriched record is written back to the database. Execution of one task instance is responsible for processing one unique id.</p>
<p><strong>Task 2 :</strong> Reads the enriched data written by step 1 for the unique id received as task argument input and generates reports. Execution of one task instance is responsible for generating reports for one unique id.</p>
<p>It should be clear from the above explanation that Task 1 and Task 2 are sequential steps. Assume that the input database contains 50k unique ids. I want to develop an orchestrator Java program that would launch task 1 with a limit of 40. (i.e only 40 pods can be running at any given time for task 1. Any requests to launch more pods for task 1 should be put on wait). Once all 50k unique ids have been processed through Task 1 instances, only then can Task 2 pods should be launched.</p>
<p><strong>What I found so far</strong></p>
<p>Going through the documentation, I found something known as the <a href="https://docs.spring.io/spring-cloud-dataflow/docs/current/reference/htmlsingle/#spring-cloud-dataflow-composed-tasks" rel="nofollow noreferrer">CompositeTaskRunner</a>. However, the examples show commands triggered on a shell/cmd window. I want to do something similar but instead of opening up a data-flow shell program, I want to pass arguments to a Java program that can internally launch tasks. This allows me to easily integrate my application with legacy code that knows how to integrate with Java code (Either by launching a Java program on-demand that should launch a set of tasks and wait for them to complete or by calling a Rest API).</p>
<p><strong>Question</strong></p>
<ol>
<li>How to programmatically launch tasks on-demand with Spring Cloud Data Flow using Java instead of a data-flow shell? (Is there a Rest-API to do this or a simple Java program that will be run on a stand alone server should be fine too)</li>
<li>How to programmatically build a sequential pipeline with an upper limit on the number of pods that can be launched per task and with dependencies such that a task can only start once the previous task completed processing all the inputs.</li>
</ol>

Chetan Kinger
<p>Please review the <a href="https://dataflow.spring.io/docs/feature-guides/batch/java-dsl/" rel="nofollow noreferrer">Java DSL</a> support for Tasks.</p>
<p>You'd be able to compose the choreography of the tasks with sequential/parallel execution with this fluent-style API. [example: <code>.definition(&quot;a: timestamp &amp;&amp; b:timestamp&quot;)</code>]</p>
<p>With this defined as Java code, you'd be able to build, launch or schedule the launching of these directed graphs. We see many customers following this approach for E2E acceptance testing and deployment automation.</p>
<p>[ADD]</p>
<p>Furthermore, you can extend the programmatic task definitions for <a href="https://dataflow.spring.io/docs/batch-developer-guides/continuous-deployment/cd-basics/" rel="nofollow noreferrer">continuous deployments</a>, as well.</p>
