How to start specific spring batch job with command line

I have two configured jobs in my spring boot application. I want to trigger a job manually, using a command in my docker-compose.yml to trigger it. To accomplish this first I disable the batch.job.enabled property in my application.yml:

batch:
   initialize-schema: always
   job:
      enabled: false

I disable it in order to not allow Spring to execute my jobs on application startup.

I'm trying to test my jobs with docker, so in my docker-compose.yml I set this command on my application service to execute when my container is up:

command: java -jar batch-application-1.0-SNAPSHOT.jar -Dspring.batch.job.names=uploadToS3Job date=2018-06-26 type=MyType

This command runs the uploadToS3Job with job parameters date and type.

When I run my application with docker-compose up --build, spring application runs smoothly but the job is not executed, nothing happens, no crash, no nothing.

But if I set this property equal true:

job:
   enabled: true

And run docker-compose up again with the same command in my docker-compose.yml, both jobs are executed.

I really don't know what to do, all I want is execute a specific job with specific job parameters using a command that I will pass in my docker-compose.

What's is wrong with this command:

command: java -jar batch-application-1.0-SNAPSHOT.jar -Dspring.batch.job.names=uploadToS3Job date=2018-06-26 type=MyType

Or what I'm doing wrong?

Upvotes: 1

Views: 4646

Answers (1)

ISlimani
ISlimani

Reputation: 1673

try

--spring.batch.job.names=uploadToS3Job

Upvotes: 3

Related Questions