Batch job properties

This is my first attempt at creating a batch job. The code to start the job is

Properties jobParams = new Properties();
jobParams.setProperty("metadataFile", group.getMetaFilename());
...
long jobId = jobOperator.start(DB_UPDATE_JOB, jobParams);

but when the job accesses the parameters

@Dependent
@Named("MetafileReader")
public class MetafileReader
    extends AbstractItemReader {
    @Inject
    private JobContext jobCtx;
...
    @Override
    public void open(
        Serializable checkpoint)
        throws Exception {
        String metadataFile =
            jobCtx.getProperties().getProperty("metadataFile");

The value is not what was set above but is the value in the DbUpdateJob.xml

<job id="DbUpdateJob" xmlns="http://xmlns.jcp.org/xml/ns/javaee"
                    version="1.0">
  <properties>
...
    <property name="metadataFile" value="wrongValue" />
  </properties>

What I’m I doing wrong? What is the purpose of JobOperator.start() Properties parameter if it doesn’t allow runtime values to be passed? Thanks for any help with this. Bernie

Hi,

The properties work a little bit different than you mention. When you start the job you can supply values for variable substitution within properties defined in the job xml.

In your case, the following config is the correct usage

<job id="DbUpdateJob" xmlns="http://xmlns.jcp.org/xml/ns/javaee"
                    version="1.0">
  <properties>
...
    <property name="metadataFile" value="#{jobParameters['actual_file']}" />
  </properties>

and

Properties jobParams = new Properties();
jobParams.setProperty("actual_file", group.getMetaFilename());
...
long jobId = jobOperator.start(DB_UPDATE_JOB, jobParams);

Regards
Rudy

That was the information I needed. It would be nice if the javadoc (or xml schema) contained a pointer to a description of that syntax. I had tried things like value="" and value="*". Thanks.