Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Concurrency in Web Services

 
Vivek Punekar
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
We are using optimistic locking using version column (JBoss + Hibernate).
Now we are planning to implement Web Services interface. My basic query is: How can we maintain data integrity?
E.g. step 1: user 1 fetches a record by sending a web service request.
step 2: user 2 in mean time modifies this record from UI.
step 3: Then user 1 modifies the record and sends it over web services to persist it.
If both these were carried from UI, user 1 would have got optimistic lock exception flow in step 3

How will the flow using web services behave? In step 3, Will user1 overwrite the changes of user 2?

Any help would be appreciated.
 
Jimmy Clark
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A web service is for two or more applications to communicate. It is a transport mechanism.

Transaction management activities and ensuring data integrity occur at a lower layer. Whether you are using a web service or not should not matter in terms of your particular transaction management design.

Transaction management should not be occuring in the UI regardless. If you code transaction management in the UI then you will need to figure out how it could be accomplished. This is not a good thing.

In step 3, Will user1 overwrite the changes of user 2?


It depends on how you write the application and how you design transaction management.
 
Vivek Punekar
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reply.

About the comment: [Transaction management should not be occuring in the UI regardless. If you code transaction management in the UI then you will need to figure out how it could be accomplished. This is not a good thing. ]
The transaction management in our case is really in the persistence layer by means of @version column.
In UI case:
1. User A clicks on List employee records: A table with employee records is displayed. User A selects first record, goes to its Edit page.
2. User B clicks on List employee records: A table with employee records is displayed. User B selects first record, goes to its Edit page.
3. User A commits his changes
4. User B commits his changes.
In my view, the action in step 4 should fail as User B was working with older version of entity (which was modified by user A in the meantime)

Please correct me or suggest.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic