cancel
Showing results for 
Search instead for 
Did you mean: 

SAP HANA XS Server - REST Web Services - How to close the connection

Former Member
0 Kudos

Hi all,

we have a REST web services based on an Hana XSJS Project; at moment the steps that the WS perform are the following :

1) Parse the Body of the POST cal

2) Make some elaboration based on the input data

3) set the HTTP 200 Status

Example of AS IS :

$.response.contentType = "text/html";

var va_br = $.request.body.asString();

// -- PERFORM ELABORATION  
$.response.setBody(output);

$.Response = $.net.http.OK;

The problem is that the connection with the client is closed only when the XSJS process complete all the operation .

Question :

How to send the HTTP Code "200" and close the connection to the client whithout waiting the XSJS code is completed .

The flow will be :

1) Parse the Body of the POST call

2) Close the connection and send the HTTP 200 Status back to the client

3) Make some elaboration based on the input data

We tried to force the closing of the objects $.response or $.response without any result .

Thank you

Maurizio

Message was edited by: Tom Flanagan

Accepted Solutions (0)

Answers (1)

Answers (1)

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

Not possible. The response will only be returned to the client once all processing is complete.  The only way to even get close to this is to use the XSJOB and schedule a job run immediately to perform the processing. Job Scheduling is available as of SPS7.

Former Member
0 Kudos

Yes,

but how to "schedule a job run immediately" at the end of the XSJS web services ?

are there any java method to call a job and pass some parameters ?

thank you

Maurizio

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

Yes there are JavaScript APIs for the scheduling of a job. They are documented in the HANA Developers' Guide:

http://help.sap.com/hana/SAP_HANA_Developer_Guide_en.pdf

Section 8.4 Using the Server-Side JavaScript APIs

Section 8.7.2 Add or Delete a Job Schedule during Runtime

Former Member
0 Kudos

Hi Thomas,

the problem here is that the web service receive 100.000 per minute from many client in parallel .

This will generate a lot of job.... do you think that this kind of architecture can be ok ?

thank you

Maurizio

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

No.  The job system isn't designed for that. I hesitated to even mention the job scheduling because it really isn't designed to be a threading model for XSJS in general. Its for batch jobs.  However technically in smaller scales than what you describe it would work.  We are planning a light threading model in XSJS for the future. However this is primarily designed around Web Sockets and not locking the XSJS thread while it waits for external activities (such as outbound HTTP requests).

Continuous 100K requests per minute is very high volumes and requires some special designs. Are you already in communication with SAP about this? Is this feeding data into HANA? Perhaps ESP (Event Stream Processor) would be a better choice to front-end HANA in that situation. 

Former Member
0 Kudos

At moment we haven't any consulting request open to SAP .

We want use SAP Hana XS because all the datawarehouse data are stored into the Hana Database and at moment we don't have other software like ESP .

The basic idea is to

- Receive the client requests via HTTP REST in the XSJS

- Resolve the request via Hana SQL in pushdown 

- Sent the resolved request by consuming an external web services on another server (non SAP) .

we can do all of this task in hana XS but at moment the problem is that the transaction betwen CLIENT/ SERVER XS the remain open...

what do you think about that ?