简体   繁体   中英

Java EE Scheduled task

I need to schedule a task to be run periodicily (eg every 6 hours, or maybe everyday at 12 PM) on Weblogic 10.3 server. The task basically retrieves some data from the database and does some business logic with it.

What is the best way to achieve this? I have searched the internet, and found some solutions like:

  • Using the Timer Service.
  • Work Managers.
  • EJB Timers.

And BTW, I am still learning JavaEE so maybe this is a basic question or I am missing something.

When running under a JavaEE container, you should avoid using the JDK's standard Timer feature. You should use EJB timers instead; favour those over any proprietary solution (I think that Work Managers are proprietary to WebLogic).

Start here: http://docs.oracle.com/javaee/6/tutorial/doc/bnboy.html

Timer timer = new Timer();
timer.schedule(new MyTask(), 1000, 2000);

考虑javax.ejb.Schedule注释

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM