CommonJ TimerManager versus EJB3 TimerService
Asked Answered
C

3

8

I have to implement a simple (not clustered) timer for WebLogic and it seems there are two different 'standard' options

  • Timer and Work Manager API (CommonJ)
  • EJB3.0 TimerService

Does anyone have any advice on using the CommonJ TimerManager versus using the EJB3 TimerService in WebLogic 10.0?

Thank you.

Cesar answered 7/7, 2011 at 7:12 Comment(0)
T
4

TimerService in EJB 3.0 is somewhat limited as compared to CommonJ Timer Manager. For example, it requires boilerplate code and container-specific configuration to implement flexible task scheduling. This was simplified with the introduction of @Scheduled annotation in EJB 3.1.

If you are stick with EJB 3.0 and need easily and flexibly configurable task scheduling, CommonJ Timer Manager API is a viable option.

In addition, Task Scheduler from Spring Framework (org.springframework.scheduling.TaskScheduler) does a good job of abstracting Timer Manager API and allows declarative configuration using cron expressions.

Tallman answered 9/1, 2012 at 16:29 Comment(1)
I finally chose CommonJ TimerManager and everything works like a charm.Cesar
C
9

CommonJ was originally proposed under JSR 237, which was withdrawn in 2008 and merged into JSR 236 Concurrency Utilities for the Java EE platform. Note that this means a significant change from CommonJ proposed standard and API. The name CommonJ is removed, the new packages are under javax.enterprise.concurrent, rather than commonj.timers and commonj.work, and the original classes TimerManager, Timer and TimerListener are replaced by non-corresponding interfaces/classes including ManagedScheduledExecutorService, ManagedTask, ManagedTaskListener, Trigger.

This latter JSR 236 has recently passed public review and, hence, should become a standard soon. As of november 2012, it is a preliminary candidate for inclusion under the Java EE 7 specification (JSR 342), but this will be confirmed once 342 is finalised and released.

Hence, the following problems with CommonJ:

  • it is not and will not be a Java standard, until significantly changed under JSR 236 which will be included in Java EE 7 or later
  • it goes beyond your requirements, presumably, and is more complicated than the EJB 3.0 Timer Service

I suggest you use the EJB 3.0 Timer Service if it meets your needs.

Chrysoprase answered 23/2, 2013 at 2:47 Comment(1)
Great explanation about what happened to CommonJCesar
T
4

TimerService in EJB 3.0 is somewhat limited as compared to CommonJ Timer Manager. For example, it requires boilerplate code and container-specific configuration to implement flexible task scheduling. This was simplified with the introduction of @Scheduled annotation in EJB 3.1.

If you are stick with EJB 3.0 and need easily and flexibly configurable task scheduling, CommonJ Timer Manager API is a viable option.

In addition, Task Scheduler from Spring Framework (org.springframework.scheduling.TaskScheduler) does a good job of abstracting Timer Manager API and allows declarative configuration using cron expressions.

Tallman answered 9/1, 2012 at 16:29 Comment(1)
I finally chose CommonJ TimerManager and everything works like a charm.Cesar
R
0

Yes, if TimeService features cover your requirements use it - it's part of the Java EE standard! Why use another library if not absolutely necessary.

Redfield answered 8/7, 2011 at 11:29 Comment(4)
CommonJ TimerManager is a JavaEE standard (jcp.org/en/jsr/detail?id=236). WebLogic comes with its own implementation (download.oracle.com/docs/cd/E12840_01/wls/docs103/commonj/…)Cesar
@antispam: Interesting, looks like 236 was proposed for inclusion into JEE6, but never made. Looking at the JEE6 technology stack it's definitely not included: oracle.com/technetwork/java/javaee/tech/index.htmlRedfield
@antispam Well JSR 236 has status Inactive which means its development has stalled. Anyway as of today it is implemented at least in WebLogic and WebSphere application servers.Jackfish
I've not tested it, but there is a CommonJ implementation to be used in other containers (commonj.myfoo.de)Cesar

© 2022 - 2024 — McMap. All rights reserved.