Announcement Announcement Module
Collapse
No announcement yet.
How to get StepExecution in service layer ? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to get StepExecution in service layer ?

    I have a scenario as explained below:
    I have a Itemwriter class which calls service layer (manager) class and this will in turn call dao layer class to do some db operation.
    Here in service layer i want to get the step execution details of the job in order to generate report for various business logic checks. I want to generate report and continue with the same record for further processing.

    I made my service class to implement StepExecutionListener. But the stepExecution is still getting as null. Am i doing anything wrong?

    I do not want to pass the stepExecution from the writer to service class as a method parameter.

    Would you please help me out to achieve this?

  • #2
    Make sure you're registering it as a listener with the step. If you use the factory beans they automatically register the reader and writer given, but you will need to manually register anything they contain.

    Comment


    • #3
      Thank you very much.
      I was using factory beans itself.
      I registered my manager as listener to the step. It worked fine.

      Comment


      • #4
        jobexecution data

        I have a job with many steps, say 5 steps.
        I am printing the step names with some other step info at the end of the job using jobexecution. But the order of steps displayed is not consistent with the order in which the steps are defined in my job.xml
        I want the step names to be displaye as in the same order it is defined in the job.xml
        Code snippet given below: Would you please help me on this?

        Collection<StepExecution> steps = jobExecution
        .getStepExecutions();

        ArrayList<Step> stepList = new ArrayList<Step>();

        for (StepExecution stepExecution : steps) {

        Step step = new Step();

        step.setStepName(stepExecution.getStepName());
        step.setSkipCount(String.valueOf(stepExecution.get SkipCount()));
        step.setItemCount(stepExecution.getItemCount().toS tring());

        stepList.add(step);
        }

        Comment


        • #5
          &quot;write-behind&quot; + rollback

          In the sample doc, it is mentioned as below:

          This "write-behind" behaviour is provided by Hibernate implicitly, but we need to take control of it so that the skip and retry features provided by Spring Batch can work effectively.

          How can we take control of "write-behind" ?

          In my case the db updates happened between the transaction are not getting rollbacked if any exception occured further?

          Would you please help me on this?

          Comment

          Working...
          X