• Post Reply Bookmark Topic Watch Topic
  • New Topic

Schedule some job  RSS feed

 
Gu Castellano
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello guys,

I need to schedule some job. When the criteria is met (the client will provide this information, like price or expiration date) I call a method. I searched for @Schedule but I don't think I can change value dynamincally.
Someone can help me ? ** I'm woking on saturday =(
 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 36453
459
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Gu,
Sorry to hear you have to work on Saturday.

You are correct that @Schedule is used when you know the schedule at deployment time. To schedule a task programatically (dynamically), take a look at the Timer Service.
 
Gu Castellano
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jeanne, thank you for reply. Timer service can help me if the condition is a time/date ... but what if its condition is a price or color (my own properties) ?
 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 36453
459
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wouldn't called that a scheduled job. The word "scheduled" implies some time associated with it. (sorry - I should have read your post more carefully).

One option is to schedule the job using time and checking if the condition is met. If not, schedule it again for the next time it should check. The other approach is to have the task that is doing the setting notify your job that it is time to resume. Read on "publish subscribe" for this approach.

 
Luan Cestari
Ranch Hand
Posts: 172
C++ Redhat Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could create a first timeout and then during the timeout call back (or also during another EJB call) you could schedule when the next time do you want the method to be called. Here you can find some example of dynamic and annotated schedule methods:

http://tomee.apache.org/examples-trunk/schedule-expression/README.html
http://tomee.apache.org/examples-trunk/schedule-methods/README.html
 
Jaikiran Pai
Sheriff
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The timer service can be used for "fire now" kind of jobs too. Of course, it won't know anything about a price change in your application. That part will have to be handled by your application specific logic.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!