Results 1 to 3 of 3

Thread: JobId in itemwriter in multithreaded app

  1. #1
    Join Date
    Aug 2009
    Posts
    15

    Default JobId in itemwriter in multithreaded app

    I need to get JobId in the itemwriter, it is multithreaded web app

    public void beforeStep(StepExecution stepExecution) {

    this.stepExecution = stepExecution;
    }

    public void write(List<? extends T> items) throws Exception {
    ExecutionContext stepContext = stepExecution.getExecutionContext();
    long jobId = stepExecution.getJobExecution().getJobId();
    }
    Using this code returns wrong job id, since beforestep method is called for each job run and so it only returns the latest run jobID.

    Is there a any other way to get jobId in item writer.
    Last edited by shriny; Mar 7th, 2010 at 02:24 PM.

  2. #2

    Default

    uh? Are you familiar with Job, JobInstance and JobExecution? Maybe reading the following will help:
    http://static.springsource.org/sprin...html#domainJob

    What is a JobId for you exactly?

  3. #3
    Join Date
    Aug 2009
    Posts
    15

    Default Job instance id

    I want to use the job instance id and I solved the issue by making all the beans scope="step"

    Thanks
    Shriny

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •