Ajit
Ajit

Reputation: 967

REST web services: synchronous or asynchrous?

What is the default behavior of REST web services - synchronous or asynchronous?
If it's synchronous then can we create asynchronous?

Upvotes: 38

Views: 69709

Answers (5)

add-semi-colons
add-semi-colons

Reputation: 18810

I think this might be a good help for you to understand the RESTful web services in Java:


You can control the client being synchronous or asynchronous from the client side. An example - using AJAX.

Upvotes: 3

techuser soma
techuser soma

Reputation: 4877

@Thrustmaster has explained it well. I just wanted to add a point to make it sound simpler.

REST web service is nothing but an HTTP call. You make a HTTP request to a URL and get a HTTP response back. How to handle the request and response is up to the caller.

Upvotes: 5

UltraInstinct
UltraInstinct

Reputation: 44444

"Synchronous" or "Asynchronous" is the behaviour of the client that is requesting the resource. It has nothing to do with REST webservice, its structure, or the supporting server.

Synchronous behaviour:

  • Client constructs an HTTP structure, sends over the socket connection.
  • Waits for the response HTTP.

Asychronous behaviour:

  • Client constructs HTTP structure, sends the request, and moves on.
  • There's another thread that is waiting on the socket for the response. Once response arrives, the original sender is notified (usually, using a callback like structure).

Upvotes: 66

Sunil Gulabani
Sunil Gulabani

Reputation: 938

Yes you can have Asynchronous as well as Synchronous Web Service. You can use any of the frameworks like Restlet, JAXB, JAX-RS.

Upvotes: 1

Subir Kumar Sao
Subir Kumar Sao

Reputation: 8401

REST services has not nothing to do with being Synchronous or asynchronous.

Client Side: Clients calling must support asynchronous to achieve it like AJAX in browser.

Server Side: Multi- Thread environment / Non blocking IO are used to achieve asynchronous service.

Upvotes: 3

Related Questions