Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revisit the default behaviour of job parameters conversion #3960

Closed
fmbenhassine opened this issue Jul 5, 2021 · 5 comments
Closed

Revisit the default behaviour of job parameters conversion #3960

fmbenhassine opened this issue Jul 5, 2021 · 5 comments

Comments

@fmbenhassine
Copy link
Contributor

fmbenhassine commented Jul 5, 2021

The current behaviour of the DefaultJobParametersConverter has been confusing in many situations:

  • The way to specify parameter types with the parameter(type)=value notation is not friendly to command line arguments and environment variables
  • The way to specify identifying / non identifying job parameters with +/- prefixes is not friendly with Spring Boot

While it is possible to provide a custom JobParametersConverter and set it on the CommandLineJobRunner or JobOperator, I believe the default behaviour should be reviewed for a better getting started experience for batch users and a better integration with Spring Boot. Since this could be a breaking change, I see v5 as a good opportunity to revisit this part of the framework.

References:

Related issues:

@lcmarvin
Copy link
Contributor

Any update on this, how to define the default parameter's format?

@lcmarvin
Copy link
Contributor

@benas Is it possible to add a command line option like -parameterFile to specify the path of job parameters file? This file could be .json, .properties or .ymal. For example,

[
    {
        "job":"fooJob",
        "parameters":[
            {
                "parameterName":"k1",
                "parameterType":"String",
                "paramter":"v1"
            },
            {
                "parameterName":"k2",
                "parameterType":"Long",
                "paramter":123,
                "identifying":true
            }
        ]
    }
]
spring.batch.job.parameters.fooJob[0].parameterName=k1
spring.batch.job.parameters.fooJob[0].parameterType=String
spring.batch.job.parameters.fooJob[0].parameter=v1
spring.batch.job.parameters.fooJob[1].parameterName=k2
spring.batch.job.parameters.fooJob[1].parameterType=Long
spring.batch.job.parameters.fooJob[1].parameter=123
spring.batch.job.parameters.fooJob[1].identifying=true
spring:
  batch:
    job:
      parameters:
        fooJob:
          - parameterName: k1
            parameterType: String
            parameter: v1
          - parameterName: k2
            parameterType: Long
            parameter: 123
            identifying: true

I think this format may be more friendly for Spring Boot users, compared with parameter(type)=value and +/-.

@fmbenhassine fmbenhassine modified the milestones: 5.0.0, 5.0.0-M6 Aug 31, 2022
@fmbenhassine fmbenhassine modified the milestones: 5.0.0-M6, 5.0.0-M7 Sep 21, 2022
fmbenhassine added a commit to fmbenhassine/spring-batch that referenced this issue Oct 4, 2022
This commit also changes the way job parameters
are parsed and persisted.

NB: This commit should ideally have been split
into two change sets. But the changes are tightly
related that is was not possible to separate them.

Related to:

* spring-projects#3960
* spring-projects#2122
* spring-projects#1035
* spring-projects#1983
fmbenhassine added a commit to fmbenhassine/spring-batch that referenced this issue Oct 4, 2022
This commit also changes the way job parameters
are parsed and persisted.

NB: This commit should ideally have been split
into two change sets. But the changes are tightly
related that is was not possible to separate them.

Related to:

* spring-projects#3960
* spring-projects#2122
* spring-projects#1035
* spring-projects#1983
fmbenhassine added a commit to fmbenhassine/spring-batch that referenced this issue Oct 4, 2022
This commit also changes the way job parameters
are parsed and persisted.

NB: This commit should ideally have been split
into two change sets. But the changes are tightly
related that is was not possible to separate them.

Related to:

* spring-projects#3960
* spring-projects#2122
* spring-projects#1035
* spring-projects#1983
fmbenhassine added a commit that referenced this issue Oct 4, 2022
This commit also changes the way job parameters
are parsed and persisted.

NB: This commit should ideally have been split
into two change sets. But the changes are tightly
related that is was not possible to separate them.

Related to:

* #3960
* #2122
* #1035
* #1983
fmbenhassine added a commit that referenced this issue Oct 4, 2022
For some DB providers, columns cannot be named "VALUE".
This commit adds a prefix where appropriate to the columns
of `BATCH_JOB_EXECUTION_PARAMS`.

Related to:

* #3960
fmbenhassine added a commit that referenced this issue Oct 4, 2022
The support to use any type as a job parameter was added
in #3960.

This commit introduces convenience methods where appropriate
to use Java 8 Date/Time APIs as job parameters.

Resolves #1035
@fmbenhassine
Copy link
Contributor Author

@lcmarvin Thank for your feedback and suggestion.

Is it possible to add a command line option like -parameterFile to specify the path of job parameters file? This file could be .json, .properties or .ymal.

This could be a feature request for the CommandLineJobRunner. This issue is rather about the DefaultJobParametersConverter, for which the entry point is a java.util.Properties instance. You can open a new issue for your feature request and we can discuss it there.

The new notation has been implemented in #4204, which is explained in the migration guide and will be documented in 5.0.0-M7.

@gulbrain
Copy link

FYI: The ERD at https://docs.spring.io/spring-batch/docs/current/reference/html/schema-appendix.html#metaDataSchema looks like it needs to be updated.

@fmbenhassine
Copy link
Contributor Author

@gulbrain Thanks for reporting this. This will be addressed in #4358, which is planned for the upcoming v5.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants