jeudi 9 avril 2015

Unable to access job parameters in reader/partitioner

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;

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());
}


}


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? Please help.


Aucun commentaire:

Enregistrer un commentaire