My application has a cron job that executes every 60 seconds. The application is configured to scale when required onto multiple instances. I only want to execute the task on 1 instance every 60 seconds (On any node).
I did the following changes as per spring profiling.
Changed the bean definition from:
<beans>
<bean id="someBean" .../>
<task:scheduled-tasks>
<task:scheduled ref="someBean" method="execute" cron="0/60 * * * * *"/>
</task:scheduled-tasks>
</beans>
To:
<beans>
<beans profile="scheduled">
<bean id="someBean" .../>
<task:scheduled-tasks>
<task:scheduled ref="someBean" method="execute" cron="0/60 * * * * *"/>
</task:scheduled-tasks>
</beans>
</beans>
Then I set the JVM property to include the below: -Dspring.profiles.active=scheduled
the above property is set on 1 of the four tomcat instances.
My job still does not run. Am i missing out on any configuration? Any guidance would be greatly appreciated. Thanks