Transaction rollback after connecting the controller stops (that is, the client has a timeout)

Scene image; I have a mobile application that takes $ 20 off a managed Spring server and waits for confirmation before marking it in the application.

Nonetheless;

  • The mobile application sends a request for output to the server

  • The controller receives the request and calls the server level, as the service level usually does not take long to withdraw money (the reason is not important).

  • The runtime of the mobile application (with SocketException), and the request is reordered until it can access the application again.

  • The server ends the request with 1, but does not know what the client is waiting for.

Now we have a scenario according to which the mobile application believes that $ 20 failed, but the server fulfilled the request.

So the questions are:

• Can a Spring transaction be canceled when the sockets are closed (that is, when the mobile application does not fulfill the request)?

• If not, what is the best approach to achieve the above?

Server Information • Spring 3.1 • Spring Controllers / Services / DAO. • Sleep Mode (JPA) • MYSQL Data Warehouse

Thanks,

Yang.

+4
source share
1 answer

Can a Spring transaction be canceled when the sockets are closed (i.e. when the mobile application expires request time)?

At the moment, I can’t imagine how this can work ...

If not, what is the best approach to achieve the above?

I would consider the problem as follows:

  • the mobile application sends some kind of token / uuid that identifies the output
  • if the request expires, the mobile application marks the output inside itself as a kind of “unknown result” state, and instead of reconfiguring the mobile application can request the server status using the token
  • The “unknown result” should be valid only for some time (for example, 5 minutes), otherwise assume that the withdrawal did not work and rescheduled.
  • the transaction on the server should also have a timeout (and meet the time of the "unknown result")

Hope this helps.

0
source

All Articles