[英]Scheduled task executed twice
I have a Stateless session bean with two @Schedules
: 我有两个
@Schedules
的无状态会话bean:
@ConcurrencyManagement(ConcurrencyManagementType.CONTAINER)
@Stateless
@Lock(LockType.WRITE)
@AccessTimeout(value = 0)
public class ScheduledTask {
@EJB
private SomeClass sClass;
@Schedules({
@Schedule(hour = "*", minute = "*/10",
info = "Automatic timer to send")})
public void send() {
sClass.doWork(true);
}
@Schedules({
@Schedule(hour = "*", minute = "*/35",
info = "Automatic timer to receive")})
public void receive() {
sClass.doWork(false);
}
}
My problem is that the tasks are executed twice. 我的问题是任务执行了两次。 I have read topic but I have not found a solution.
我已阅读主题,但未找到解决方案。
I have in console the same output (like (EJB default - 1) and (EJB default - 2)): 我在控制台中有相同的输出(例如(EJB默认-1)和(EJB默认-2)):
INFO [GENERAL_LOGGER] (EJB default - 2) resultForSend.size() = 500
INFO [GENERAL_LOGGER] (EJB default - 1) resultForSend.size() = 500
The solution was to remove the EJB class from a WAR module. 解决方案是从WAR模块中删除EJB类。 I had the same class in two separate modules - the EJB and WAR - inside EAR and hence the
Schedules
were registered twice. 我在EAR内部的两个单独的模块(EJB和WAR)中拥有相同的类,因此
Schedules
被注册了两次。 A silly mistake during packaging that resulted in the double execution. 包装过程中的一个愚蠢错误导致重复执行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.