I am trying to pass an object between packages, but I ran into a problem while trying to access the context job from a partitioned step (batch program).
According to JSR 352 specification
9.4.1.1 Life cycle and batch context context: A batch context has thread similarity and is displayed only for a batch of artifacts running on that particular thread. An incentivized batch context field may be blank if it is out of scope. Each type of context has a scale and a life cycle as follows: 1. JobContext There is one JobContext for the job. He exists for life to work. There is a separate JobContext for each substream parallel execution (for example, a partitioned step). 2. StepContext There is one StepContext action for each step. He exists for life. Step. For a partitioned step, there is one StepContext for the parent step / stream; There is a separate StepContext for each substream.
My (unsuccessful) solution was to use JobContext.setTransientUserData, but since the partitioned step uses a separate JobContext, I cannot get TransientUserData.
Is there an alternative to what I'm trying to do? Using the PartitionMapper properties is not possible because I need to pass an object, not a string, for each section.
To be clear, I need to do the following:
- NormalBatchlet → Save the object that will be used in the next step.
- PartitionedBatchlet -> Get the saved object in the previous step. This object is not a simple string, so using PartitionMapper properties is not a solution.
UPDATE
Now I use a simple Singleton EJB with a HashMap to store objects between stages and when the task is completed. I clean this card to avoid resource leakage.
, javax.batch EJB, .