tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matej <gma...@gmail.com>
Subject Re: EJB timers stop working.
Date Wed, 11 Feb 2015 15:04:23 GMT
No log was noticed. But maybe we missed it. We will look further. But
definitely no periodic log.

Like that:

@Singleton
@Lock(LockType.READ)
public class TimerScheduler {

    @Resource
    private TimerService timerService;
    @Inject
    Logger logger;
    @Resource
    private BeanManager beanManager;

    public void scheduleEvent(ScheduleExpression schedule, Object event,
Annotation... qualifiers) {

        timerService.createCalendarTimer(schedule, new TimerConfig(new
EventConfig(event, qualifiers), false));
    }

    @Timeout
    private void timeout(Timer timer) {
        final EventConfig config = (EventConfig) timer.getInfo();

        beanManager.fireEvent(config.getEvent(), config.getQualifiers());
    }

    private final class EventConfig implements Serializable {

        private final Object event;
        private final Annotation[] qualifiers;

        private EventConfig(Object event, Annotation[] qualifiers) {
            this.event = event;
            this.qualifiers = qualifiers;
        }

        public Object getEvent() {
            return event;
        }

        public Annotation[] getQualifiers() {
            return qualifiers;
        }
    }
}

2015-02-11 15:54 GMT+01:00 Romain Manni-Bucau <rmannibucau@gmail.com>:

> Hi
>
> how do you use TimerService? No log at all saying there is an issue?
> What's @Timeout method?
>
>
> Romain Manni-Bucau
> @rmannibucau
> http://www.tomitribe.com
> http://rmannibucau.wordpress.com
> https://github.com/rmannibucau
>
>
> 2015-02-11 15:48 GMT+01:00 Matej <gmatej@gmail.com>:
> > Hi all.
> >
> > In production under load, we experienced a case were a particular timer
> > stopped working.
> >
> > I thought maybe a runstime exception stops a ScheduleExpression, but
> could
> > not simulate this. Glassfish I know was very sensible to this.
> >
> > Could a low EJB timer thread seeting cause a timer to stop, working.
> >
> > We use tomee 1.7
> >
> > The timer is initialized like that.
> >
> > @Singleton
> > @Lock(LockType.READ)
> > @Startup
> > public class CommEtaUpdateCacheTimer {
> >
> >     @Inject
> >     private TimerScheduler scheduler;
> >
> >     @PostConstruct
> >     public void doit() {
> >         final ScheduleExpression schedule = new ScheduleExpression()
> >                 .hour("*")
> >                 .minute("*")
> >                 .second("*/5");
> >
> >         scheduler.scheduleEvent(schedule, new
> > CommEtaUpdateCacheTimerEvent());
> >     }
> >
> >     public void observe(@Observes CommEtaUpdateCacheTimerEvent event) {
> > /*
> > processing code.
> > */
> >
> >     }
> >
> >     public static class CommEtaUpdateCacheTimerEvent {
> >     }
> > }
> >
> > BR
> >
> > Matej
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message