wicketwicket-6wicket-1.5wicket-1.6wicketstuff

Handling simultaneous action


I have a GUI screen which consist of 2 buttons, Check Balance and Create Saving. Once any user enters the customer ID and click on 'Check Balance' , details of the customer including their balance will be shown and simultaneously 'Create Saving' button will be enabled(after clicking on 'Check Balance' button as initially it will be disabled).

I have an scenario which i will try to explain with an example :

There are 2 users X & Y, who have logged in at the same time, and have clicked the "Check Balance" at the same time for a customer Id say 12345. Both see customer balance including some more details about customer and the "Create Saving" button is enabled for both of them.

every time a saving is created, technically "Check Balance" are always invoked, thus always refreshed values are considered before creating a saving in the back end. In the above scenario, though the User X sees outdated value in the screen, the saving is always created considering the saving created by User Y.

Any suggestion will be much appreciated.Thanks.


Solution

  • when you click on "Create Saving" you could send the outdated amount or a timestamp indicating when it was retrieved. Then on server side when "Check Balance" is invoked you could check if the actual amount has changed and if so, you might redirect user to an intermediate page informing him/her and asking if the saving operation should be aborted or not.

    Hope this could help.