Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Schedule some job

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 =(
 
author & internet detective
Posts: 41085
848
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 41085
848
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

 
Ranch Hand
Posts: 172
Redhat Ruby C++
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
My honeysuckle is blooming this year! Now to fertilize this tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic