0

I am getting below error while running spring batch application

A job instance already exists and is complete for parameters={}. If you want to run this job again, change the parameters.

I have tried below things and few times application will up but most of the time it is not working

JobParameters jobParameters = 
                      new JobParametersBuilder()
                      .addLong("time",System.currentTimeMillis()).toJobParameters();

                    JobExecution execution = jobLauncher.run(job, jobParameters);
                    System.out.println("Exit Status : " + execution.getStatus());

Code for executing process for each 5 sec. Tried to change it to 60 sec but same issue.

 <bean id="runScheduler" class="com.test.sync.RunScheduler" /> <task:scheduled-tasks> <!-- <task:scheduled ref="runScheduler" method="run" fixed-delay="5000" /> --> <!-- fixed-delay use instead of cron post checking--> <task:scheduled ref="runScheduler" method="run" cron="*/5 * * * * *" /> </task:scheduled-tasks>

DataSource

<property name="dataSource" ref="dataSource" />
        <property name="queryProvider">
            <bean
                class="org.springframework.batch.item.database.support.SqlPagingQueryProviderFactoryBean">
                <property name="dataSource" ref="dataSource" />
                <property name="selectClause" value="SELECT *" />
                <property name="fromClause" value="FROM TBL_CHANGE_EVENT" />
                <!--  include INpROGRESS AS -->
                <property name="whereClause" value="WHERE THREAD_KEY &gt;= :fromId AND THREAD_KEY &lt;= :toId AND STATUS in ('Not Started','In Progress')" />
                <property name="sortKey" value="EVENTTIME" />
            </bean>
        </property>


            <bean id="dataSource"
            class="org.springframework.jdbc.datasource.DriverManagerDataSource">
            <property name="driverClassName" value="oracle.jdbc.driver.OracleDriver" />
            --given my DB details
            <property name="url" value=" " />
            <property name="username" value="" />
            <property name="password" value="" />
        </bean>
andrew
  • 79
  • 9

0 Answers0