spring-cloud / spring-cloud/spring-cloud-task

PartitionedHandler: How to pass the step name as an input argument ?

Open
#791 1 comment 0 reactions 0 assignees View on GitHub

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.