我想读取CVS文件并将其每24小时插入到数据库中。我使用Spring Schedular并按预期工作,但我的应用程序将部署在3个不同的JVM和所有JVM将同时运行,那么对于所有三个JVM,schedular将只运行一次,因此它每天只能插入一次数据。Spring Scheduler每24小时
<bean id="runMeTask"
class="com.fifththird.ebusiness.ivr.core.service.RunMeTask" >
<property name="dataSource" ref="DataSource"/>
</bean>
<bean id="schedulerTask"
class="org.springframework.scheduling.timer.MethodInvokingTimerTaskFactoryBean">
<property name="targetObject" ref="runMeTask" />
<property name="targetMethod" value="printMe" />
</bean>
<bean id="timerTask"
class="org.springframework.scheduling.timer.ScheduledTimerTask">
<property name="timerTask" ref="schedulerTask" />
<property name="delay" value="1000" />
<property name="period" value="60000" />
</bean>
<bean class="org.springframework.scheduling.timer.TimerFactoryBean">
<property name="scheduledTimerTasks">
<list>
<ref local="timerTask" />
</list>
</property>
</bean>
添加到上面的问题:“如果部署在三个不同的JVM相同apllication将拨打电话去春来程序器,那么代码将尝试三次/日来插入数据。”
Thnx为您的答案,但如果两个JVM同时呼叫锁定,该怎么办? – user970500
两个JVM不能同时获得文件上的锁定 –