java - How to write a fallback mechanism that saves entities that weren't successfully saved the first time -


I am trying to write a mechanism that will manage my saved in DB operation.

I have a list of server objects, it overlaps them and saves everyone.

Now, if they fail for some strange reason (exception) then they save them in the other list, which every 5 seconds the timer tries to save them again.

Then I have a locking problem, which I can solve with any other boolean.

My function is to protect the object lost me:

  private void SaveLostDeals () {synchronized (unsavedDeals) {if (unsaved) (To) ( ) (for (DealBean unsavedDeal: unsavedDeals) {boolean successfully unsaved were = report translates (Shela, false, false); if (successfully saved) deals unsaved {. extracted (saved without saving);}} }}}   

and my report delays () method is being called for regular reports and lost deals For the report:

  Try {...} Hold (Hibernate Expression E) {... if (fallback) synchronized (unsaved Dell) {unsavedDeals.add (deal);} Session.getTransaction (). Rollback ();} Finally {....}   

Now, when a lost deal is saved - If there is an exception - the synchronized block will stop it

What do you have to say about this to save the fallback mechanism? Are there better design patterns to deal with this common problem?

I suggest to use rollback / one or aspects to try again. The proxy could use something like patterns for what action to advise.

If you do not want to try again immediately, but as you propose, in 5 seconds, I started to associate that database with my database level contract, asynchronous routine Provide consideration. dao.scheduleStore (o); or dao.asyncStore (o); Something like

Comments

Popular posts from this blog

qt - switch/case statement in C++ with a QString type -

python - sqlite3.OperationalError: near "REFERENCES": syntax error - foreign key creating -

Python's equivalent for Ruby's define_method? -