简体   繁体   English

乐观锁定和并发

[英]Optimistic locking & concurrency

My application working in a multi-users environment for medical records. 我的应用程序在多用户环境中工作以获取病历。 One of the important parts of the application is writing the medical records, doctors should always review the current written data then adding or correcting any information's as needed. 该应用程序的一个重要部分是编写医疗记录,医生应该始终查看当前的书面数据,然后根据需要添加或更正任何信息。

I were aware about the situation when 2 doctors (A,B) viewing the data at same time, one of them will make changes and hit save (A). 当两位医生(A,B)同时查看数据时,我知道了这种情况,其中一位将进行更改并点击保存(A)。

the other doctor (B) still editing the old data & he don't know about the changes applied by doctor (A). 另一位医生(B)仍在编辑旧数据,他不知道医生(A)所采用的变化。

When doctor (B) hit save, the application will compare the Version column in the database, application then return an error message ("Data has been changed by another user !!!"). 当医生(B)点击保存时,应用程序将比较数据库中的Version列,然后应用程序返回错误消息(“数据已被其他用户更改!!!”)。

My Question in this case: What choices should be available within my solution. 在这种情况下我的问题:我的解决方案中应该有哪些选择。

I'm seeking an professional solution or idea from your experiences. 我正在寻求您的经验中的专业解决方案或想法。

My application using: Java Swing for end user client & MySQL database. 我的应用程序使用:Java Swing用于最终用户客户端和MySQL数据库。

Doctor B should absolutely be notified in some way that the record has been modified since he opened it. 医生乙方应绝对以某种方式,因为他打开了它的记录已修改通知。 The rest is up to you/the requirements of the program. 其余的由您/程序的要求决定。 Does it matter if Doctor A's changes are overwritten? A医生的改变是否被覆盖是否重要? Would it be better to have Doctor B view the changes made by Doctor A, and then decide if the changes (made by Doctor B) should still be saved? 让医生B查看医生A所做的更改,然后决定是否仍应保存更改(由医生B做出)会更好吗? Should the changes be merged? 这些变化应该合并吗? It all depends on what you decide to design, as well as any requirements that may be imposed on the system you are creating. 这一切都取决于您决定设计的内容,以及可能对您正在创建的系统施加的任何要求。 Without more detail on the system you are designing or its requirements, it would be impossible to provide a specific answer. 如果没有关于您正在设计的系统或其要求的更多细节,则无法提供具体答案。

suggestion: send a real time notification 建议:发送实时通知

if A makes changes and hits save you could send a message "Data has been changed by another user !!!" 如果A进行更改并点击保存,您可以发送消息“数据已被其他用户更改!!!” immediately to B before B saved his changes. B保存他的更改之前立即到B。

This approach is similar to stackoverflow. 此方法类似于stackoverflow。 As I write my answer, you can change your question and I will get a message 当我写下答案时,你可以改变你的问题,我会收到一条消息

an edit has been made to this post; 已对此帖进行了编辑; click to load 点击加载

So if A,B,C... open data set D, they should register themselves as observers. 因此,如果A,B,C ......打开数据集D,他们应该将自己注册为观察者。 You can implement this approach by using websockets or polling. 您可以使用websockets或轮询来实现此方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM