java - How to avoid Concurreny from front end -
java - How to avoid Concurreny from front end -
we have requiremnt manager log in site , see list of user record in table format. when click on record detail of user , phone call user resolve issue.now possible 2 manager login , click on same record , phone call same user @ same time. want avoid this.
condition 1 : 2 manager login @ same time record available both in normal color green. manager 1 click on record , start editing/calling user. in case there should kind of lock if manager 2 tries open same record pop message 'in progress'.
condition 2 : manager 1 login , see record in greenish color. manager 2 login , see same record in gray color. should not able click record.
+++++++++++++++++
manager1: select status, ver_no record record_id=? (ver_no zero) click on record see detail , update record set status='in progress', ver_no=1 record_id=? , ver_no=0 (ver_no 1 - success)
now manager 2 login after time , manager 1 has not closed record means status still in progress or closed browser straight manager2: select status, ver_no record record_id=? (ver_no 1) click on record see detail , manager2: update record set status='in progress', ver_no=1 record_id=? , ver_no=1 (ver_no 1 - success)
this case optimistic locking scenario. work in backend server code. cannot lock user using java script on front end end.
let me explain in simple terms how this:
add version number column , status flag database table. on record table.
manager 1 clicks on record, select record database first, increment version number , update flag saying record picked up.
manager 2 clicks on record, (if @ same manager 2 select same record selected manager 1). when manager 2 tries update record, version number not match , update homecoming no rows updated. utilize update ui saying record in progress.
the conversation below:
manager1: select status, ver_no record record_id=? (ver_no zero) manager2: select status, ver_no record record_id=? (ver_no zero) manager1: update record set status='in progress', ver_no=1 record_id=? , ver_no=0 (ver_no 1 - success) manager2: update record set status='in progress', ver_no=1 record_id=? , ver_no=0 (this fail update row)
the above in case both attack same row @ same time. of time when manager 2 selects itself, status in progress. if not can work record.
java javascript oracle11g
Comments
Post a Comment