This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Journey To Enterprise Agility and have Daryl Kulak & Hong Li on-line!
See this thread for details.
Win a copy of The Journey To Enterprise Agility this week in the Agile and Other Processes forum! And see the welcome thread for 20% off.
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

Retry mechanism..Urgent!  RSS feed

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • 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)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • 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 ]
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!