adesai
adesai

Reputation: 420

Deploy Spring Batch application on Spring Cloud Data Flow by running the batch microservice separately

I have a Spring batch application where I would like to have two options to trigger the batch:

  1. Expose a REST api
  2. Scheduler

By packaging the batch application as Task, I am able to deploy the application on SCDF server running separately. I am creating an application of type Task on SCDF server and referring to the jar file of the batch app. And then creating a Task with the application Task.

I am aware that SCDF expose rest interface to trigger a task on schedule basis as well as one off however I would like to keep the trigger in the batch itself as we have a requirement to expose REST interface with a separate definition.

Is it possible to run Spring batch application separately as a Spring boot microservice and register as a task with SCDF server?

Upvotes: 1

Views: 672

Answers (1)

Sabby Anandan
Sabby Anandan

Reputation: 5651

Is it possible to run Spring batch application separately as a Spring boot microservice and register as a task with SCDF server?

No, a Task definition in SCDF is required to be present for you to take advantage of SCDF's RESTful endpoints to either launch or schedule it for recurring runs. There's no mechanism in SCDF to automatically also discover an arbitrary batch-job that is running standalone. Unless the footprint is established from within SCDF, we do not have any tracking ability to manage the standalone apps.

One other important distinction to note re: Tasks. Tasks in SCDF are ephemeral. They start, execute the business operation, and they get shut down when the business logic completes.

For this core design to work in cloud platforms like Kubernetes and Cloud Foundry, we do not expect the Task/batch apps to be bundled with RESTful controllers. And, likewise, no health-checks are available for Tasks. The moment you add the RESTful nature, it is then required to be run as a long-running application (because you want the endpoint to be accessible from other services), which will violate the design premise of Tasks in cloud platforms.

Upvotes: 2

Related Questions