Announcement Announcement Module
Collapse
No announcement yet.
scheduled batch runs more than once Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • scheduled batch runs more than once

    Hi,

    I'm using a SimpleJobLauncher with SimpleAsyncTaskExecutor to run a batch with a daily cron. The cron runs at the proper time, but it runs like 60 times in a row for some odd reason. I've invoked the jobLauncher manually and insured that my code doesn't actually run the batch 60 times. Any ideas what it could be? My config is below:

    Code:
    <beans:bean id="jobLauncher" class="org.springframework.batch.core.launch.support.SimpleJobLauncher" >  
    		<beans:property name="jobRepository" ref="jobRepository"/>
    		<beans:property name="taskExecutor">
    			<beans:bean class="org.springframework.core.task.SimpleAsyncTaskExecutor" />
    		</beans:property>
    
    <beans:bean id="exportUserListTasklet" class="com.foo.batch.jobs.userlist.ExportUserList" />
    		<batch:job id="exportUserListJob" job-repository="jobRepository">
    			<batch:step id="exportUserListJobStep0">
    				<batch:tasklet ref="exportUserListTasklet" transaction-manager="jobRepository-transactionManager" />
    			</batch:step>
    		</batch:job>	
    
    <task:annotation-driven executor="taskExecutor" />
    	<task:executor id="taskExecutor" pool-size="5-25" queue-capacity="100" rejection-policy="DISCARD" />
    	<task:scheduler id="taskScheduler" pool-size="10"/>
    	
    		<!-- TASKS -->
    		<beans:bean id="exportUserListTask" class="com.foo.tasks.ExportUserListTask">
    			<beans:property name="buildEnvironment" value="${BUILD_ENVIRONMENT}" />
    		</beans:bean>
    		</beans:bean>
    	
    	<task:scheduled-tasks scheduler="taskScheduler">
    		<task:scheduled ref="exportUserListTask" method="run" cron="* 1 21 * * *" />
    	</task:scheduled-tasks>
    Thank you in advance!

  • #2
    the cron expression triggers the launch every second (between 21:01 and 21:02, every day). Is it what you want?

    Comment


    • #3
      arno,

      No, I'd just like it to execute at 21:01 every day. Is the cron expression similar to the system cron flags?

      Comment


      • #4
        No, I'd just like it to execute at 21:01 every day.
        ok, so your cron expression should be 0 1 21 * * * instead of * 1 21 * * *. This one should also work: 0 1 21 * * ? (you don't specify the day twice, but it doesn't matter in this case).

        Is the cron expression similar to the system cron flags?
        cron expressions in Spring (and Quartz) use the same syntax as the system cron's ones (e.g. *, ?, 0/*, etc.), except there's an additional field for seconds (on the left). The last field (on the right) is for years, but it's optional.

        Comment

        Working...
        X