spring-cloud / spring-cloud/spring-cloud-task
PartitionedHandler: How to pass the step name as an input argument ?
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 446
- Forks
- 310
- Avg merge
- 18h 18m
- Merged PRs (30d)
- 6
Description
Hello,
In the partitioned-batch-job project, the partitioned handler is created as follows:
@Bean
public PartitionHandler partitionHandler(TaskLauncher taskLauncher, JobExplorer jobExplorer, TaskRepository taskRepository) throws Exception {
...
DeployerPartitionHandler partitionHandler = new DeployerPartitionHandler(taskLauncher, jobExplorer, resource, "workerStep");
...
return partitionHandler;
}
How could I pass the step name, here "workerStep", as an input argument. I tried to modify the method like below:
@Bean
public PartitionHandler partitionHandler(TaskLauncher taskLauncher, JobExplorer jobExplorer, TaskRepository taskRepository, String stepName) throws Exception {
...
DeployerPartitionHandler partitionHandler = new DeployerPartitionHandler(taskLauncher, jobExplorer, resource, stepName);
...
return partitionHandler;
}
and I adapted the job/step definition, but it didn't work. I got an exception saying that the method requires a bean of the type String that wasn't found. Then I defined a bean:
@Bean
public String stepName() {
return new String();
}
and the exception is gone. But I don't think that might be a solution.
Could you please advise ?
Many thanks in advance.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the partitioned-batch-job example and the partitionHandler bean shown in the issue; trace how DeployerPartitionHandler receives its step name and how Spring resolves method parameters. Check the relevant configuration or reference documentation, then document a supported way to supply a non-hard-coded name and verify the example starts successfully.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100