4
votes

I've got a strange behavior with scheduled tasks. I've got the following settings

<task:scheduled-tasks>
      <task:scheduled ref="servicioEjecucionReportes" method="ejecutar" cron="0 0 * * * *" />
      <task:scheduled ref="servicioEjecucionReportes" method="ejecutarReintentos" cron="0 30 * * * *" />
      <task:scheduled ref="servicioEjecucionReportes" method="enviarReporteDiario" cron="0 15 0 * * *" />
</task:scheduled-tasks>

And the executor is configured this way:

<task:annotation-driven executor="asyncExecutor" scheduler="taskScheduler" />
<task:executor id="asyncExecutor" rejection-policy="CALLER_RUNS" pool-size="16" />
<task:scheduler id="taskScheduler" pool-size="8" />

The thing is, we're developing using linux and mac os and the three of the tasks get executed properly, but on the deployment server which is Windows 7 Server, the first two got executed correctly and the third one does not.

I need the third task to execute every day at 00:15.

I've tried changing configurations, but the behavior is always the same, on development and testing environments everything works well, but not on the production environment.

I'm kind of lost on where to look or what is wrong with this.

The bean is declared like this:

<bean id="servicioEjecucionReportes" class="com.mycompany.beans.ServicioEjecucionReportesImpl" />

And the interface is:

public interface ServicioEjecucionReportes {

   public void ejecutar();

   public void ejecutarReintentos();

   public void enviarReporteDiario();
}

EDIT: Extra info, on the server logs we dont see even the task trying to run, the spring version is 3.1.0.

2
Again this is speculation but can you just try removing rejection policy?? Or change it to "DISCARD_OLDEST" ?? - Anuj Patel

2 Answers

1
votes

There seems to be problems with scheduled async methods in Windows. This is related on how the JVM creates threads on Windows

Try removing the @Async and check if it works

0
votes

Speculation: Are any of your tasks very long running in the production environment by any chance - ejecutar or ejecutarReintentos. What I am wondering is may be your asyncExecutor threadpool is exhausted which triggers the Caller_RUNS on your scheduler, and may be there is no more scheduler pool available at all?