
Parallel Processing Requests
Use
It is possible to send requests to various servers in parallel and to wait for all the responses simultaneously. The method
LISTEN is then used to find out which request is being responded to.This is worthwhile if several requests have been assigned to different servers with widely differing response times.
Activities

Extend the program above by adding the following lines.
The following is an extra parameter with which you can specify whether the method
LISTEN should be used and how many requests should be sent:|
parameters: listen type c default space, times type i default '1', … |
Now the system waits for the responses to the requests. The responses are received in the order in which the server sends them.
|
* receiving with listen (parallelizing #times requests) do times times. if not listen is initial. call method client->listen receiving client = cclient exceptions http_communication_failure = 1 http_no_open_connection = 2 others = 3. if sy-subrc <> 0. call method client->get_last_error importing code = subrc message = dummy. write: / listen’, / 'code: ', subrc, 'message: ', dummy. exit. endif. |
The incoming responses are re-assigned to the requests.
|
* Assigning responses to requests * If there are more requests, accept all responses client = cclient. call method client->receive exceptions http_communication_failure = 1 http_invalid_state = 2 http_processing_failed = 3 others = 4. if sy-subrc <> 0. call method client->get_last_error importing code = subrc message = dummy. write: / 'communication_error( receive )', / 'code: ', subrc, 'message: ', dummy. exit. endif. ... enddo. |
You can then specify how often a request should be dropped (parameter
times). You can see in the output the order in which the responses were received. This does not have to be the order in which the requests were sent.
The ABAP code above is only a simple example, and is not an example of professional work!