0

In my application, the browser http requests are queued.

On http request to server, the client should be notified by server that the request is been accepted (say with http status as 202 or just a message "In Progress"), so that client side queue can send the second request to server.

Once the first request executes completely, the client should be again notified by server saying the request is success (say http status as 200).

Using promises didn't help as two times rendering was not possible; one with actual request-response and the other when the thread completes the work.

Though I know one request and multiple response are not possible. But is there a way to render the text at least twice for a request?

Vinay Prajapati
  • 7,199
  • 9
  • 45
  • 86
shishank
  • 1
  • 1
  • A standard Grails controller can only issue a single response. If you need something that has the ability to issue multiple responses you will need to look into something along the lines of Atmosphere. – Joshua Moore Oct 27 '15 at 21:32
  • thanks for sharing this. – shishank Oct 28 '15 at 07:51

1 Answers1

0

One solution is to do it as multi step process.

So, suppose we are using Rabbit MQ as our messaging queue. Let's follow steps below:

  1. Queue sent out a request to server that process some resource.
  2. Server accepted the request and started processing it and sent out a return message with code 202 / in process. Also, it did send a message to rabbit mq to process the request meanwhile sending out the message code to client.

  3. The other message got consumed and process completed and pushed the message 200 to say success queue with some identification number to identify the request from client e.g. customer id, urn no. etc. Or rather than pushing just put a message status in database and use another call from client to check if the message status is updated to the expected one.

  4. Client can now easily check the status of it's request by checking up the queue or database.

You may use ajax requests as well to track if some process is completed or not as server side.

Hope it helps.

Vinay Prajapati
  • 7,199
  • 9
  • 45
  • 86