I have following configuration for my spring batch partitioner(excluded itemreader and other step details) -
<bean id="myPartitioner" class="com.MyPartitioner" scope="step">
<property name="param" value="#{jobParameters['myparam']}" />
</bean>
<batch:step id="ReadStep" >
<batch:tasklet transaction-manager="transactionManager">
<batch:chunk reader="itemReader" processor="itemProcessor" writer="mysqlItemWriter" commit-interval="100"/>
</batch:tasklet>
</batch:step>
<batch:job id="myjob">
<batch:step id="Step1">
<batch:partition step="ReadStep" partitioner="myPartitioner">
<batch:handler grid-size="40" task-executor="taskExecutor"/>
</batch:partition>
</batch:step>
</batch:job>
And partitioner code -
public class MyPartitioner implements Partitioner{
String myparam;
public void setMyparam(String myparam) {
this.myparam = myparam;
}
public String getMyparam() {
return myparam;
}
@Override
public Map<String, ExecutionContext> partition(int gridSize)
{
System.out.println("JobParam = "+getMyparam());
}
}
Quartz job Launcher-
public class SpringBatchJob implements Job{
@Override
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException
{
ApplicationContext applicationContext =new ClassPathXmlApplicationContext("myjob.xml");
JobLauncher jobLauncher = (JobLauncher) applicationContext.getBean("jobLauncher");
org.springframework.batch.core.Job job = (org.springframework.batch.core.Job) applicationContext.getBean("jobName");
JobParameters param = new JobParametersBuilder().addString("myparam", "myparam").addString("time",Long.toString(System.currentTimeMillis())).toJobParameters();
JobExecution execution = jobLauncher.run(job, param);
}
}
But when the System.out.println
executed instead of printing actual jobparameter value I am receiving #{jobParameters['myparam']}. Is there some configuration wrong in here?
Aucun commentaire:
Enregistrer un commentaire