我正在运行一个Web应用程序,它使用带有spring webservice的java / j2ee和作为后端的oracle 11g。我使用eclipse链接作为JPA也使用数据源,我的服务器是web逻辑10.6。
场景,出于某种原因,由于无法建立后端连接(在生产中),我的数据库连接丢失了。同时一些用户正在进行CRUD操作以获取一些细节。由于背面连接错误,它会抛出错误。
例如,我有5个不同的请求,要求在连接错误时提供一些数据。无论如何,一旦可用就执行它们。无论如何,一旦连接可用,在连接失败时执行失败的事务。
我正在寻找实现这个想法的一些想法。
答案 0 :(得分:0)
假设您的数据库服务器可以在以后的任何时间启动,您可以做的是:
a) Create a separate table for monitoring your tasks(A set of operations).
Say table - 'Task_Monitor'.
b) Whenever you start a task, you first make entry to the Task_Monitor table with the status of the task as In_PROGRESS and the web service url to which the response has to be sent.
Task_Name Status REQ_IDENTIFIER
--------- ------ --------------
TaskA IN_PROGRESS url hoes here
c) start performing the task. Once it is completed update the status of the task in the table to, SUCCESS, send the response to the url mentioned in REQ_IDENTIFIER. If it fails due to some SQLException update it to FAIL.
Task_Name Status REQ_IDENTIFIER
--------- ------ --------------
TaskA SUCCESS/FAIL url
d) Now your App should have a seperate thread which keeps on polling the Task_Monitor table to check if any tasks are in FAIL state.
e) If so, perform the failed task(follow steps b and c) and update the task status to success.