java - Accesing JobContext from a partitioned step in JSR 352 -


i'm trying pass object between batchlets, i've encountered problem when trying access jobcontext partitioned step (batchlet).

according jsr 352 specification

9.4.1.1 batch context lifecycle , scope: batch context has thread affinity , visible batch artifacts executing on particular thread. batch context injected field may null when out of scope. each context type has distinct scope , lifecycle follows: 1. jobcontext there 1 jobcontext per job execution. exists life of job. there distinct jobcontext each sub-thread of parallel execution (e.g. partitioned step). 2. stepcontext there 1 stepcontext per step execution. exists life of step. partitioned step, there 1 stepcontext parent step/thread; there distinct stepcontext each sub-thread.

my (failed) solution use jobcontext.settransientuserdata, because partitioned step uses distinct jobcontext can't transientuserdata.

is there alternative i'm trying do? using partitionmapper properties it's not possible because need pass object, not string every partition.

to clear, need this:

  1. normalbatchlet -> save object used in next step.
  2. partitionedbatchlet -> obtain saved object in previous step. object isn't simple string using partitionmapper properties not solution.

update

i'm using simple singleton ejb hashmap store objects between steps , when job finished clear map avoid resources leak.

this workaround because want use javax.batch package , not depend on ejb's, i'm not putting answer.

you try should conform current spec programming model.

store object first step using persistent step data in normalbatchlet:

stepctx.setpersistentuserdata(myserializabledata); 

retrieve data first step in partitions, looking previous step:

long execid = jobctx.getexecutionid();  list<stepexecution> stepexecs = joboperator.getstepexecutions(execid);  mypersistentuserdata mydata;  (stepexecution step : stepexecs) {     if (step.getstepname().equals("somepreviousstepx") {         mydata = (mypersistentuserdata)step.getpersistentuserdata();     } }  //use mydata 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -