Question

I am developing an application where I am using messaging queue. The workflow is as shown below user submits a request --> request goes to the queue --> process the task --> show output to the user.

I am currently using Iron MQ and possibly Amazon SQS (depends on the performance) with Laravel PHP. I have been able to send the message to the queue but not able to display the output to the user. Am I missing something here? Do I need to write the output to the database/file then poll it continuously and then show the output to the user? Any help will be much appreciated

PS: Here the output is user specific and depends on the input. So every user will have unique output.

Was it helpful?

Solution

Generally messages are for background processing like Antonio said, but you can poll (or push using websockets) to get the results after the background process is completed. Basically anytime you see a progress bar or spinner on a website after you've clicked something, that is what's happening.

So the process is:

  • User submits a request (clicks a button or performs some action)
  • A message is put on a queue (IronMQ in your case) for processing and a response is returned to the user immediately so user doesn't have to wait for processing.
  • The page that is displayed to the user will start polling to check if the task is complete and will generally have some indicator that something is happening (progress bar or spinner or "please wait while processing").
  • Worker process picks up the message and processes it.
  • When finished, the worker stores results in a data store (cache, database, s3, etc)
  • Page that is polling will know that the task is complete by checking the data store and then display the results.

Here's a good article on various polling options: http://techoctave.com/c7/posts/60-simple-long-polling-example-with-javascript-and-jquery

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top