0

Partition Plan won't work when inside a split

The following example is just a: job -> split -> flow -> step -> chunk -> partition

The problem is that the parameters set in the partition plan wont work if I put the flow inside a split. If you delete the split and just put the flow inside the job, it works properly. The following example wil print just: null null

but if I delete the split, it will print valueTest1 valueTest2

Thanks! Matias

Job XML

<job id="myJob" xmlns="http://xmlns.jcp.org/xml/ns/javaee" version="1.0">
      <split id="mySplit">
        <flow id="myFlow">
            <step id="myStep" >
                <chunk>
                    <reader ref="testbatch.MyItemReader">
                        <properties>
                            <property name="prop1" value="#{partitionPlan['prop1']}"/>
                        </properties>
                    </reader>
                    <writer ref="testbatch.MyItemWriter"/>
                </chunk> 
                <partition>
                    <plan partitions="2" > 
                        <properties partition="0"> 
                            <property name="prop1" value="valueTest1"/> 
                        </properties>
                        <properties partition="1"> 
                            <property name="prop1" value="valueTest2"/> 
                        </properties>
                    </plan>
                </partition>   
            </step>
        </flow>
    </split>
</job> 

READER

package testbatch;

import javax.batch.api.BatchProperty;
import javax.batch.api.chunk.AbstractItemReader;
import javax.inject.Named;

@Named
public class MyItemReader extends AbstractItemReader {

    @BatchProperty
    String prop1;

    @Override
    public Object readItem() throws Exception {
        System.out.println(prop1);
        return null;
    }
}

MAIN

package testbatch;

import javax.batch.operations.JobOperator;
import javax.batch.runtime.BatchRuntime;

public class TestBatch {

    public static void main(String[] args) {
        JobOperator jobOperator = BatchRuntime.getJobOperator();
        jobOperator.start("myJob", null);
    }
}
Aacini
  • 65,180
  • 12
  • 72
  • 108

1 Answers1

0

This is the bug reported here on the jbatch (JSR 352 RI) implementation.

The 1.0.1 version should contain the fix when released (undergoing Glassfish integration testing now).

Scott Kurz
  • 4,985
  • 1
  • 18
  • 40