This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Murach's Python Programming and have Michael Urban and Joel Murach on-line!
See this thread for details.
Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Retry mechanism..Urgent!  RSS feed

 
babu krishnan
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
 
Stan James
(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 ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!