• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Retry mechanism..Urgent!

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I'm developing an application that interacts with database. Whenever my custom code gets a notification(from some other database or application), I need to invoke some methods. These methods are API's that interact with database.
My problem is that if database is down, my custom code has to wait for some sleeptime, say for 10 mins. And then retry again to connect to database, if succeds then proceed else throw error and get out.
How do I implement this sleeping - retry mechanism? Please help me in this .
Thanks in advance
K.Babu
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm surprised you haven't gotten an answer from some of the smarter folks here, so I'll give a try. Look into starting a new thread for your retry logic. It can wait the ten minutes, then wake up and try the operation again. Consider the Command Pattern for putting all the logic that you want to try and retry into a Command class. Consider the Active Object pattern to handle a queue of Commands. I haven't been able to find a clear example of Active Object this morning, but the one I'm thinking of looped through a set of queued commands each of which had a "execute me at this time" variable. If the time had come, it removed and executed the command, else it left the command there to re-inspect the next time through.
Any time you spawn an operation on a new thread, you may have to figure out how to get the results back to the original requester. Consider Listener or Publish Subscribe for that. I have a page on Messaging that gets into some of the asynchronous issues.
[ August 26, 2003: Message edited by: Stan James ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic