Asynchronous Web Services Streaming

I need a framework that will help me make asynchronous transfer over http. It may look like SOAP WS or somethign else. I don't know if I called it correctly, so here is what I need:

ServerA wants to make a request to the remote server via http. The request contains arbitrary information. The result for it will contain several records of the same type. Some of them are available immediately, others are available later. ServerA wants to get the results as soon as possible, without waiting for all the results to be available. In the real world, ServerB will look for various data sources, some of which are more responsive than others.

I can think of three types of solutions. First, ServerA generates a random request identifier, executes a SOAP request

void ServerB.startSearch(id, request); 

which will return immediately and then A periodically calls

Result[] ServerB.areThereAnyNewResults(id);

So, ServerA polls ServerB for new results. I call this polling method. It includes several connections established from A to B. Another solution is to expose the receipt of the service on the ServerA side, for example

ServerA.acceptResults(String id, Result[] newResults); 

and call

ServerB.startSearch(id, request, serverAReceivingServiceEndpoindAddress);

So ServerB creates new results for ServerA.acceptResults () when new results are available. I call it pushing. It includes 1 connection established from A to B, and a multiple connection established from B to A.

Another option is to transmit the results over the same HTTP channel within the same response.

A HTTP- ( , SOAP - ), B , HTTP- , . http-, . A B, . . , , - - , .

, , - , . , , A

Service s = new RemoteAsyncService("http://serverb.com/serviceEndpoint", RemoteAsyncService.STREAMING); 
// or RemoteAsyncService.POLLING, or RemoteAsyncService.PUSHING
Request r = new Request(...);
Callback callback = new Callback(){
 void newResults(Result[] result){...}
 // e should be null if finished correctly
 void requestFinished(RemoteException e){...}
}
s.search(request, callback);

ServerB

public ServiceImpl implements Service{
  void search(Request r, Callback c){
   // perform search, call c.newResult() when new results are available
  }
}

, , , /, - , callback.requestFinished(), ServerB , .. Probbaly, .

, - , , , ?

, , ?:)

+3
1

, , COMET. :

()

, - Java, .NET WCF. , :

+1

Source: https://habr.com/ru/post/1706755/


All Articles