1

i am trying to apply task scheduling in spring mvc . the problem that i faced is when the function which is scheduled is called then its is called twice . i want that the function only called once . i am attaching the code of controller and application-config.xml . please help me to sort out this problem.

@Scheduled(cron = "0 0 1 * * ?")
@Async
public void WorkFlowPerformActionFunction() {
    System.out.println("hello we are in workflow function");

}

the code in application-config.xml

  <beans xmlns="http://www.springframework.org/schema/beans"  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:task="http://www.springframework.org/schema/task" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.0.xsd">
<task:scheduler id="taskScheduler"/>
<task:executor id="taskExecutor" pool-size="10"/>
<task:annotation-driven executor="taskExecutor" scheduler="taskScheduler"/>

the output is :

 hello we are in workflow function

 hello we are in workflow function

i want that the function called only once not twice.

  • 1
    Possible duplicate of [Java Spring @Scheduled tasks executing twice](http://stackoverflow.com/questions/14242310/java-spring-scheduled-tasks-executing-twice) – Bohuslav Burghardt Oct 21 '15 at 07:49

0 Answers0