临时备份表,如果进程失败还原
我有一个应用程序,该应用程序会定期下载大XML并将其保存到数据库中。在插入过程中处理故障的正确方法是什么?当前过程:
- 下载XML
- 解析XML
- 清除当前数据
- 插入数据到数据库< =跨越8个不同表上的数千行,
我希望能够在步骤4之前进行备份,并且如果步骤4失败,则从备份中恢复数据。目前使用Ebean进行持久性。我试图使用临时表并在此处复制所有数据,如果失败的情况复制了数据,但是我不确定如何在等待4次完成时保持单个会话。
I have an application that periodically downloads a large XML and saves it into a database. What is the proper way to deal with failure during the insertion process. Current process:
- download XML
- parse XML
- clear current data
- insert data into database <= spans thousands of rows over 8 different tables
I would like to be able to do a backup before step 4 and if step 4 fails restore the data from backup. Currently using ebean to do persistence. I was trying to use temporary tables and copy all data there and if case of failure copy data back, but I am not sure how to hold on to a single session while waiting for 4 to finish.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用 savepoint 参见 ebean 中的保存点:
交易.setnestedusesavepoint():
you can use Savepoint see savepoints in ebean:
transaction.setNestedUseSavepoint() :