Hello TomEE friends,

I'm seeing this timer fire twice every 15s. I vaguely remember a bug in EJB
where the bean was getting invoked twice, does that ring a bell?


```
@Singleton
@Lock(LockType.READ)
@TransactionAttribute(TransactionAttributeType.REQUIRED)
@Interceptors({ XaUuidInterceptor.class, TlehInterceptor.class })
public class SyncTimer {
        private static final AtomicInteger ai = new AtomicInteger(0);
        private static final AtomicBoolean lock = new AtomicBoolean(false);
        @Inject
        private ChunkDownloadController controller;
        @Inject
        private Logger log;

        @Schedules({
                        @Schedule(second = "0/15", minute = "*", hour = "7-18", 
dayOfWeek =
"1-5", persistent = false, info = "businessHoursSyncTimer"),
                        @Schedule(second = "0", minute = "0", hour = "0-6", 
dayOfWeek = "1-5",
persistent = false, info = "weekMorningSyncTimer"),
                        @Schedule(second = "0", minute = "0", hour = "19-23", 
dayOfWeek = "1-5",
persistent = false, info = "weekEveningSyncTimer"),
                        @Schedule(second = "0", minute = "0", hour = "*", 
dayOfWeek = "0,7",
persistent = false, info = "weekendHourlySyncTimer"), })
        public void run(Timer timer) {
                log.info("run() timer.info:{}, ai:{}", timer.getInfo(),
ai.incrementAndGet());
                if (lock.compareAndSet(false, true)) {
                        try {
                                controller.downloadLatestChunk();
                        } finally {
                                lock.set(false);
                        }
                }
        }
}
```

cheers,
-Jonathan



--
Sent from: http://tomee-openejb.979440.n4.nabble.com/TomEE-Dev-f982480.html

Reply via email to