We have three web services (/a
, /b
, /c
) where each service maps to a method (go()
) in a separate Java class (ClassA
, ClassB
, ClassC
).
Only one service should run at the same time (ie: /b
cannot run while /a
is running). However as this is a REST API there is nothing to prevent clients from requesting the services run concurrently.
What is the best and most simple method on the server to enforce that the services don't run concurrently?
Update: This is an internal app, we will not have a large load and will just have a single app server.
Update: This is a subjective question as you can make different arguments on the general application design which affects the final answer. Accepted overthink's answer as I found that most interesting and helpful.
Your design is flawed. The services should be idempotent. If the classes you have don't support that, redesign them until they do. Sounds like each of the three methods should be the basis for the services, not the classes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With