3

I'm going to write a simple REST webservice for downloading files from server( a simple GET method) The question is: Do I have to handle concurrency in this situation or the web server is going to do that?

3 Answers 3

2

It depends on what you mean by "handle concurrency". Do you have to write code to spawn threads on each incoming request? No, Jersey will create a new thread for each request before it calls your API method. Do you need to worry about a DELETE request coming in when somebody else is GETing a file? Yup.

Sign up to request clarification or add additional context in comments.

Comments

2

Hmm, bit of a vague question but:

  • Depends on how you implement the REST service, using JAX-RS?
  • Depends on the server you are running it on.
  • What do you mean by "handle concurrency"? Since REST is stateless, concurrency should be none of your concern.

3 Comments

I'm using jeresy and tomcat
Statelessness is a responsibility of the programmer, it is not a guarantee of the technology ;) That would be the true answer: stick to the stateless design philosophy of the standard (REST) and stick to the documentation of the API (JAX-RS) and you needn't worry.
If it's not stateless, it's not a REST webservice. So assuming we are building a REST webservice we can deduce statelesness.
1

If yo're using only method-local variables, concurency is not an issue (container handles this).

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.