A
A
Alexey_gr2015-03-06 14:49:11
Java
Alexey_gr, 2015-03-06 14:49:11

How to organize sequential execution of the same requests for the user?

My project uses spring and jdbc to read / write to the sql database.
There are a bunch of users who update their information. It is necessary to somehow block repeated requests to the database, i.e. there is a writeToDb(...) method inside several storedProcedure calls, it is necessary that for the current user, simultaneous calls to this method work sequentially. If he called the endpoint on the server two or more times in a row, then the first request will be executed first, after it completes the second, and so on.
In general, how is it easier to organize transactions at the user level for a specific method?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Cheremisin, 2015-03-06
@leahch

There are several options: the first - by locks of the mutex type, the second by queues with a flag.
But, in fact, the database itself should resolve it with its locks and transactions!
we started the transaction, we do the work, we committed it. if the data inside the transaction has become invalid, then the database will roll back the transaction, and return an error to us.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question