Java Reference
In-Depth Information
EJB 3.1 Java 6
(December 2009)
The container sets the TimerService object automatically; no injection is
required.
The business logic must be placed in a method annotated with @Schedule
or @Schedules .
The schedule is set in the annotations attributes and bycalendar‐based
EJB timer expressions.
EJB 3.2 Java 7
(June 2013)
This extended the EJB Lite group to include the nonpersistent EJB timer
service.
Includes enhancements to the TimerService API that allows access to all
active timers in the EJB module.
Restrictions on Timer and TimerHandle that obliged references to be
used only inside a bean have been removed.
WAR STORY
Recently, I was brought in to consult on a web project that was suffering from
intermittent performance issues. These issues had only appeared recently—just as
the site's visitor numbers started to accelerate.
The developers had chosen to use a No‐SQL database to persist GPS data regarding
the location of the site's visitors. This was a good decision because this particular
No‐SQL data store was adept at geospatial queries.
Queries were regularly run against the database, which collated data from the
location collection and aggregated it to generate reports. These reports generated
daily visitor statistics and were executed every day by a junior staff member.
After some investigating, I discovered that the performance issues the application
was having coincided with the time the reports were being run. The extra hit to
the database caused by running the reports was responsible for the deterioration in
performance.
The solution was quite simple. Run the reports when the database was experiencing
lower use. After reviewing the database usage reports, I determined that the
optimal time to run the reports was 03:00 GMT. Clearly, I couldn't ask the junior
member of the staff to start work at 3:00 in the morning, so I decided to automate
the generation of the reports and coni gured the timerservice to launch the report
generation.
Many tasks are best run in off hours for the same reason as spelled out here.
Repopulating data caches is a common example of a heavy process that should be
run when the effect on site performance is minimal.
Search WWH ::




Custom Search