Announcement Announcement Module
Collapse
No announcement yet.
Move csv file to sucess or error directory Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Move csv file to sucess or error directory

    Hi,

    I want to move the csv file to error directory or sucess directrory.

    Solution :

    1. developp a Tasklet
    2. Use JobExecutionListener (test the status of job execution)

    In the both solution , i didn' find how can i get the file name (path of file name) wiche is processed ?


    can someone help me please.

    <job id="coJob" job-repository="jobRepository"
    restartable="true">

    <step id="coStep">
    <tasklet>
    <chunk reader="coItemReader" writer="coItemWriter"
    commit-interval="10" retry-limit="3" skip-limit="10">
    <retryable-exception-classes>
    <include
    class="org.springframework.dao.DeadlockLoserDataAc cessException" />
    </retryable-exception-classes>
    <skippable-exception-classes>
    <include
    class="org.springframework.batch.item.file.FlatFil eParseException" />
    </skippable-exception-classes>
    </chunk>
    <listeners>
    <listener ref="coSkipListener" />
    </listeners>
    </tasklet>

    </step>
    <listeners>
    <listener ref="coListener" />
    </listeners>
    </job>

    <!-- **************************** -->
    <!-- Step Listener -->
    <!-- **************************** -->
    <beans:bean name="coListener" class="com.batch.listener.CoListener"/>

    <beans:bean name="coSkipListener" class="com.batch.listener.CoAuditSkipListener">
    <beansroperty name="auditEvent" ref="auditEvent"/>
    </beans:bean>

    Thanks

  • #2
    if the input file is part of the job parameters, you can query the JobExecution/StepExecution to get access to it.

    Comment


    • #3
      Hi , thanks.

      The file name isn't a job parameter.

      the file name is in properties file.

      <beans:bean name="coItemReader"
      class="org.springframework.batch.item.file.FlatFil eItemReader">
      ...
      <beansroperty name="resource"
      value="file:${PROJECT_HOME}/${file.collaborator}" />
      </beans:bean>

      1. So how can access to this resource from JobExecutionListener or from a Tasklet ??

      2. Another question : From job , how can i access to the application context (context.getBean(..))


      Thanks

      Comment


      • #4
        you can use use dependency injection in your job listener:

        Code:
        <bean id="jobListener" class="MyJobListener">
          <property name="file" value="file:${PROJECT_HOME}/${file.collaborator}" />
        </bean>
        if it works in the item reader, there's no reason it wouldn't in the job listener.

        Comment

        Working...
        X