Project

General

Profile

Support #1178

WResource

Added by PaweĊ‚ Olidale over 10 years ago. Updated over 10 years ago.

Status:
Feedback
Priority:
Normal
Assignee:
-
Target version:
-
Start date:
03/07/2012
Due date:
% Done:

0%

Estimated time:

Description

I want to add api to my wt-application for example:

1. I send request to wt-app:

myapp.com/getdata?param1&param2

2. I want to get response in json array (simple text without wt js code and html)

I did it using WtResource but i have problem when there are a lot of request and big json data.

1. Client1 -> send request 1 and wait for response (json data).

  1. Client2 -> send request 2 and wait for response (json data).
  2. Client1 -> got response.
  3. Client2 -> got response.

Client2 is waiting for response until first request will be finished.

Is there way to do it asynchronously?

Regards Paul

#1

Updated by Koen Deforche over 10 years ago

  • Status changed from New to Feedback

Hey,

There are several aspects to this.

First, you should probably deploy a resource for a public "api" (i.e. web services), as a global (static) resource, which is then not specific to a session.

Secondly, for both static (global) and dynamic (session specific) resources, Wt will not serialize access (not in the built-in httpd and not in Wt itself, not even when requesting resources from the same session). So the behavior you observer does not make sense, unless:

  • somewhere in your code locking is being done to access the "json" data ?
  • or, you are actually not using a multi-threaded build or are only using a single thread ?
  • we've got a bug ?

Finally, if you are planning to transmit big resources, you should consider using response continuations, which allows transmission of a big response in chunks, freeing the thread and avoiding large memory allocations.

Regards,

koen

Also available in: Atom PDF