Revision 46885
Added by Michele Artini about 7 years ago
AsyncClientUtils.java | ||
---|---|---|
9 | 9 |
import org.springframework.stereotype.Component; |
10 | 10 |
import org.springframework.web.client.RestTemplate; |
11 | 11 |
|
12 |
import eu.dnetlib.services.AsyncInvocation; |
|
13 |
|
|
12 | 14 |
@Component |
13 | 15 |
public class AsyncClientUtils { |
14 | 16 |
|
... | ... | |
16 | 18 |
|
17 | 19 |
private static final Map<String, AsyncClientCallback> activeRemoteCalls = new HashMap<>(); |
18 | 20 |
|
19 |
public void invokeRemoteMethod(final String remoteBaseUrl,
|
|
21 |
public Map<String, String> invokeRemoteMethod(final String remoteBaseUrl,
|
|
20 | 22 |
final String remoteMethod, |
21 | 23 |
final String localBaseUrl, |
22 | 24 |
final Object o, |
... | ... | |
26 | 28 |
|
27 | 29 |
log.info("invoking async method: " + url); |
28 | 30 |
|
29 |
final String id = (new RestTemplate()).postForObject(url, o, String.class);
|
|
31 |
final AsyncInvocation async = (new RestTemplate()).postForObject(url, o, AsyncInvocation.class);
|
|
30 | 32 |
if (callback != null) { |
31 |
activeRemoteCalls.put(id, callback);
|
|
33 |
activeRemoteCalls.put(async.getId(), callback);
|
|
32 | 34 |
} |
35 |
|
|
36 |
return async.getInfo(); |
|
33 | 37 |
} |
34 | 38 |
|
35 | 39 |
public boolean processResponse(final String id, final AsyncResponse response) { |
Also available in: Unified diff
Partial response of async methods