lundi 14 février 2022

In a Create method , how to deal with the situation that data has been stored but operation failed?

I’m writing a scheduler module for job scheduling. In the Create method, my code will

  1. store the job info into database
  2. add the job to a scheduler instance

But I don’t know how to deal with the scenario that the job info has been stored into database but failed to be added to the scheduler. I want to make sure the jobs in database and scheduler are consistent. My current way is to delete the job info in database once the second step fail. Does that make sense? Or is there any other best practice? Thanks!

Aucun commentaire:

Enregistrer un commentaire