سؤال

I have a Stateless session bean with two @Schedules:

@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)):

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. I had the same class in two separate modules - the EJB and WAR - inside EAR and hence the Schedules were registered twice. A silly mistake during packaging that resulted in the double execution.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top