I am attempting to send multiple responses at certain interval of time for a http-request from client.I am using Spring Boot RESTful web serives which receives a request from AngularJs client. RESTFul web services will get list of jobs from client, i need to send response to the client after the completion of each Job.
@PostMapping("/runExecution")
public Object sendingMultipleResponse(String input){
for(Object obj : ListOfJobs){
//performs business logic
return object;
}
}
Consider 10 Jobs are there in the lists, i need to return the results to the request after the execution of each job. NOTE: For a single request from AngularJs, i need to send multiple responses
You can use WebSocket
for your scenario.
WebSocket
provides full duplex communication channel between a server and client.
When client sends message (let say request
in this case) on server, server will start processing the message and server will respond to the client with the response message (it will be response
) like sending status of the message being processed or status of the job that has been triggered by the message sent over the WebSocket
.
Please refer link
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With