1

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.

ace120387
  • 15
  • 6
  • not an answer to your question, but it might help you out: http://vimeo.com/64703617 / http://blog.iron.io/2013/05/laravel-4-ironmq-push-queues-insane.html – Gadoma Aug 29 '13 at 12:43
  • Messages are made for background processing (sending mails, image processing, credit card approval...), I don`t see a workflow where you get your message worked and a result sent back to your user directly on a web page, you might need to poll your database to get the status of your tasks. – Antonio Carlos Ribeiro Aug 29 '13 at 12:49
  • Ok thanks, in that case I guess I had to use a database. I'm new to queues, so this might be dumb. But is it possible to use one more queue as output queue and the browser reads the queue till it find the message with correct user id and displays the output? – ace120387 Aug 29 '13 at 13:00

1 Answers1

2

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

Travis Reeder
  • 38,611
  • 12
  • 87
  • 87
  • Hello @travis-reeder … the link is dead. Could you provide a working link after that many years? Thank you – MonTea Oct 05 '22 at 09:47
  • Sorry, that's not my website and I don't remember what was there. Long polling like it says in that link isn't that common anymore though I don't think. – Travis Reeder Oct 05 '22 at 19:54